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