Jump to content
xisto Community
Sign in to follow this  
nancmu

Checking Form check for validate

Recommended Posts

Hi all,

I'v code that checking for your form.

 

How's works?

- When input text was emptied or up to you(you said s/he must enter text more than the value or anything else).

- When it was worked, the message will show under input box.

 

// java script for checking form.<script type="text/javascript"><!--function checkValidable() {  var check = 0;  var v1 = document.loginForm.Name.value.length;  var v2 = document.loginForm.StID.value.length;  if (v1 < 1) {    check = 1;    note1.style.display = ''; // show Name's warning  }  else {    note1.style.display = 'none'; // hide Name's warning  }  if (v2 < 1) {    check = 1;    note2.style.display = ''; // show StID's warning  }  else {    note2.style.display = 'none'; // hide StID's warning  }  if (check) {    return false;  }  else {    return true;  }}//--></script>// begin forn<form action="" name=loginForm onSubmit="return checkValidable()"><table>  <tr>    <td>Name</td>    <td>	<input type=text size=20 name=Name>	<div id=note1 style="display: none; color: red">Please Enter Your Name</div> // show when invalid input    </td>  </tr>  <tr>    <td>Student ID</td>    <td>	<input type=text size=20 name=StID>	<div id=note2 style="display: none; color: red">Please Enter Your ID</div>  // show when invalid input    </td>  </tr>    <td></td>    <td>	<input type=submit name=submit value="Submit">    </td>  </tr></form>// end form

Hope you will enjoy :D .

 

P.S. However you can't rely on the checking from computer's user.

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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.