Jump to content
KateMacwil

My Field Validation Code Not Working

Recommended Posts

Hi

I have tried to write some js code to validate the fields on my form and Im doing something wrong and
can't figure out what it is.

Here is my form code:

      <form name="Form1" action="">
      <table id="form_corners">
      <tr>
      <td>Name:</td>
      <td><input type="text" id="name" name="name" size="50" maxlength="60" onblur="ValidateField(name)" /></td>
      </tr>
      <tr>
      <td>Email:</td>
      <td><input type="text" id="email" name="email" size="50" maxlength="60" onblur="ValidateField(email)" /></td>
      </tr>
      <tr>
      <td width="120">Phone #:</td>
      <td><input type="text" id="phone" name="phone" size="50" maxlength="60" onblur="ValidateField(phone)" /></td>
      </tr>
      <tr>
      <td valign="top">Note:</td>
      <td><textarea id="note" name="note" rows="3" cols="39"></textarea></td>
      </tr></table>
      <br/>
      <div align="center">
      <input id="submit-btn-contact" type="submit" value="Send Now">
      </div>
     </form>

      <form name="Form1" action="">
      <table id="form_corners">
      <tr>
      <td>Name:</td>
      <td><input type="text" id="name" name="name" size="50" maxlength="60" onblur="ValidateField(name)" /></td>
      </tr>
      <tr>
      <td>Email:</td>
      <td><input type="text" id="email" name="email" size="50" maxlength="60" onblur="ValidateField(email)" /></td>
      </tr>
      <tr>
      <td width="120">Phone #:</td>
      <td><input type="text" id="phone" name="phone" size="50" maxlength="60" onblur="ValidateField(phone)" /></td>
      </tr>
      <tr>
      <td valign="top">Note:</td>
      <td><textarea id="note" name="note" rows="3" cols="39"></textarea></td>
      </tr></table>
      <br/>
      <div align="center">
      <input id="submit-btn-contact" type="submit" value="Send Now">
      </div>
     </form>

 

validate.js

Share this post


Link to post
Share on other sites

What happens when you run that, what exactly is the problem?

Share this post


Link to post
Share on other sites

The Javascript thinks that name, email, and phone are the names of variables.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×