Jump to content

Recommended Posts

the folowing is an extract of a code that i wouild like some help with.

i want on submit the code to give a  warning that some fields are null and that the user should fill them in.

 

 

 

function ref()

{

var reference;

reference=document.myForm.file_ref.value;

if (reference=="")

{

window.prompt('All fields must be filled');

return false;

window.focus=document.myForm.file_ref.file_ref;

}

esle

{

return true;

}

}

</script>

</head>

 

<body>

<?pHp include "connection.php"; ?>

<div align="center">

 

  <p>DATA CAPTURE INTERFACE  </p>

</div>

<?php

mysql_select_db("lands",$connection) or die(mysql_error());

$sql="select file_ref from data_entry order by file_ref desc limit 1";

$result=mysql_query($sql);

//$num=mysql_numrows($result);

if ($result==0)

{

$fr="1";

}

else

{

$select=mysql_fetch_array($result);

$field=$select['file_ref'];

$fr=++$field;

 

}

?>

 

  <p> </p>

  <p> </p>

<form id="form1" method="post" action="" onsubmit="return ref()">

Link to comment
https://forums.phpfreaks.com/topic/164498-invalid-entry/
Share on other sites

function ref() {
  var e = document.getElementById('form1');
  for (i = 0; i < e.childNodes.length; i++) {
    if (e.childNodes[i].tagName.toLowerCase().match(/(?:input|select|textarea)/)) {
      if (!e.childNodes[i].value) { alert('Missing Fields'); return false; }
    }
  }
}

Link to comment
https://forums.phpfreaks.com/topic/164498-invalid-entry/#findComment-867719
Share on other sites

RussellReal thanks for the help but am still having a small problem.let me post the entire form that is being affected by the onsubmit code

 

<td><select name="series">

  <?php

  $sql="select * from series";

  $result=mysql_query($sql);

  while($row=mysql_fetch_array($result))

{

$val1=$row['series'];

  ?>

  <option value="<?php echo $val1; ?>"><?php echo $val1; ?></option>

  <?php

  }

  ?>

      </select>

      </td>

      <td height="33"><input name="file_ref" type="text" value="" size="5" /></td>

      <td><select name="type">

  <?php

  $sql="select * from file_types";

  $result=mysql_query($sql);

  while($row=mysql_fetch_array($result))

{

$val1=$row['type'];

  ?>

  <option value="<?php echo $val1; ?>"><?php echo $val1; ?></option>

  <?php

  }

  ?>

      </select>

   

      <input name="subj_ref" type="text" size="30" /></td>

      <td><select name="file_miss">

        <option value="YES">Y</option>

        <option value="NO" selected="selected">N</option>

      </select>      </td>

      <td><select name="restore">

        <option value="YES">Y</option>

        <option value="NO" selected="selected">N</option>

      </select></td>

      <td><select name="investigate">

        <option value="YES">Y</option>

        <option value="NO" selected="selected">N</option>

      </select></td>

      <td><select name="remarks">

  <?php

  $sql="select * from remarks";

  $result=mysql_query($sql);

  while($row=mysql_fetch_array($result))

{

$val1=$row['remarks'];

  ?>

  <option value="<?php echo $val1; ?>"><?php echo $val1; ?></option>

  <?php

  }

  ?>

            </select></td>

      <td><select name="locality">

  <?php

  $sql="select * from locality";

  $result=mysql_query($sql);

  while($row=mysql_fetch_array($result))

{

$val1=$row['locality'];

  ?>

  <option value="<?php echo $val1; ?>"><?php echo $val1; ?></option>

  <?php

  }

  ?>

            </select></td>

      <td><input name="vol_no" type="text" size="5" /></td>

    </tr>

  </table>

<p>

 

  <input name="submit" type="submit" />

  <input type="hidden" name="subject_repl" />

  <input type="hidden" name="loc_repl" />

Link to comment
https://forums.phpfreaks.com/topic/164498-invalid-entry/#findComment-867725
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.