Jump to content

Form Validation


sharon5467
 Share

Recommended Posts

Here's an example for you, uses a regular expression:

Title>Text box with capitals before numbers?Post>text box that the user has to enter two letters before digits
<html><head><title>sharon5467 Field Checker</title><script type="text/javascript">function ckForm(form){var re = /^[A-Z]{2}\d+$/;      if(!re.test(form.elements['t1'].value)){      alert('Try Correct Format..');      return false;      }return true;}</script> </head><body><form onsubmit="return ckForm(this)"><input type="text" name="t1" size="10"><p><input type="submit"></p></form></body></html>

Some links for you:http://www.w3schools.com/js/js_form_validation.asphttp://www.siteexperts.com/tips/functions/ts23/page3.aspDevMoPost back if you need any help.Thanks,

Link to comment
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
 Share

×
×
  • Create New...