HI, HE IS MY FORM, I WOULD LIKE TO THE PHP CODE TO : DISPLY A MESSAGE IF THE ONE FIELD OR OTHER IS EMPTY,

<form id="form1" name="form1" method="post" action="form.php">
   <label>
  NAME:
 <input type="text" name="name" id="name" />
  </label>
 <p>
   Address:
    <label>
    <input type="text" name="address" id="address" />
    </label>
  </p>
</form>

THANK YOU VERY MUCH

Recommended Answers

All 8 Replies

Hi, he is my post, i would like you to : try it yourself first
thank you very much

You can do it with php or javascript but it is not safe as some visitors surfing with js-disabled browsers. Check this <URL SNIPPED>free php contact form with field validation and captcha

Member Avatar for diafol

Where's your code? Show us what you've got so far.

Use a simple javascript function to do this.
and you just need to invoke a method in event 'onsubmit' in form tag

While calling check whether any field is null or not
if 'null' then the function should return false
otherwise true.

also you can set focus to the null field to make it more user friendly.

Hi ero10,

It is you?.

It is it's code

<head>
      <script type="text/javascript">
          function heisit() {
                  if(form1["name"]["value"].length==0)
                        return false;
                   if(form1["address"]["value"].length==0)
                        return false;

                  return true;
          }
      </script>
 </head>

.....
<form id="form1" name="form1" method="post" action="form.php"  onsubmit="return heisit()" >   <label>  NAME: <input type="text" name="name" id="name" />  </label> <p>   Address:    <label>    <input type="text" name="address" id="address" />    </label>  </p>
 <input type="submit" name="cmd" value="Submit"/>
</form>
 <form action="rogh.php" method="post">
 <table width="50%" border="0" bgcolor="#CCCCFF">
 <td bgcolor="#0066FF" ><font color="#CCCCCC"><h2>OPERATING SYSTEM<img src="../../Users/HP/Desktop/images.jpg" /></h2></td>
<tr>
 <td> Q.1: Virtual memory is ?</td> 
 </tr>

<tr>
  <td><input type="radio" name="vm" value="avm"> an extremely large main memory. <?php if($_POST['vm']=="avm")  {echo "<label  style='font-size:10; color:white'>  Correct </label>"; } ?>


</td>
  </tr>

  <tr>
  <td><input type="radio" name="vm" value="bvm"> an extremely secondary memory.<?php if($_POST['vm']=="bvm")    {echo "<label  style='font-size:10; color:white'>  Incorrect </label>"; } ?></td>
  </tr>

  <tr>
  <td><input type="radio" name="vm" value="cvm"> an illustion of an extremely large memory<?php if($_POST['vm']=="cvm")   {echo "<label  style='font-size:10; color:white'>  Incorrect</label>"; } ?></td>
</tr>

<tr>
  <td><input type="radio" name="vm" value="dvm"> a type of memory used in super computer<?php if($_POST['vm']=="dvm")   {echo "<label  style='font-size:10; color:white'>  Incorrect</label>"; } ?></td>
</tr>

<tr>
<td> -----------------------------------------------------------------------------------</td>
</tr>


<tr>
 <td> Q.2: Spatial locality refers to the problem that once a location is referenced ?</td> 
 </tr>

<tr>
  <td><input type="radio" name="sl" value="asl"> an extremely large main memory. <?php if($_POST['sl']=="asl")  {echo "<label  style='font-size:10; color:white'>   incorrect</label>"; } ?></td>
  </tr>

  <tr>
  <td><input type="radio" name="sl" value="bsl"> an extremely secondary memory.<?php if($_POST['sl']=="bsl")    {echo "<label  style='font-size:10; color:white'>   Incorrect</label>"; } ?></td>
  </tr>

  <tr>
  <td><input type="radio" name="sl" value="csl"> an illustion of an extremely large memory<?php if($_POST['sl']=="csl")   {echo "<label  style='font-size:10; color:white'>  correct</label>"; } ?></td>
</tr>

<tr>
  <td><input type="radio" name="sl" value="dsl"> a type of memory used in super computer<?php if($_POST['sl']=="dsl")   {echo "<label  style='font-size:10; color:white'>  Incorrect </label>"; } ?></td>
</tr>

<tr>
<td> -----------------------------------------------------------------------------------</td>
</tr>


should be any empty radio button kindly tell me

kindly tell me

Member Avatar for diafol

what do you want? Does this post have any relation to the original post?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.