Jump to content

Add Vallidation to More Textfields


yandoo

Recommended Posts

Hi there,

 

I  have a simple form and vallidation that is ONLY setup to work on one textfield "field2". Im trying to add the vallidation to the other textfields in the form.....

 

Please help, How can i do this?????

 

Heres the JS between the <HEAD's>:

<script type="text/javascript">
function validate(form){
  if(!form.field2.value.length){
    alert('Please enter a value');
    form.field2.focus();
    return false;
  }
  return true;
} 
</script>

 

And heres the form with the valiidation Added to ONLY "field2":

 

<form method="post" name="form1" action="<?php echo $editFormAction; ?>" onsubmit="return validate(this);">
     ID:
      <input type="text" name="ID" value="" size="32">
   
     Field1:
      <input type="text" name="field1" value="" size="32">

     Field2
      <input type="text" name="field2" value="" size="32">
   
      <input type="submit" value="Insert record">
   
  <input type="hidden" name="MM_insert" value="form1">

</form>

 

Kind Regards

Link to comment
https://forums.phpfreaks.com/topic/101262-add-vallidation-to-more-textfields/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.