Computing.Net > Forums > Programming > Validation of entry in javascript

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Validation of entry in javascript

Reply to Message Icon

Name: priti
Date: October 12, 2003 at 12:57:51 Pacific
OS: WIn 2000
CPU/Ram: P4
Comment:

Hi,
I am writting a javascript for validation of the form. I want to validate the each entry as I enter them, such as once i enter name it should be validated before i enter phone number etc..
For example validation criterias are as follows:
1. name should be more than one character
2. phone number should be atleast 7 digit
3. ssn would be atleast 5 digits.

I tried to do following but it won't works.
<form name="form1" enctype="text/plain" method="POST" >

*Name: <input TYPE="TEXT" SIZE="30" NAME="myName" onBlur ="validate(this)" >

*Phone: <input TYPE="TEXT" SIZE="15" NAME="phone" onBlur ="validate(this)" >
<input TYPE="BUTTON" VALUE="(e.g 123-455-6789)">

*Age: <input TYPE="TEXT" SIZE="3" NAME="age" maxlength="2" onBlur="validate(this)">

*Social Security: <input TYPE="TEXT" SIZE="11" NAME="ssn" onBlur="validate(this)">
<input TYPE="BUTTON" VALUE="(e.g 123-45-6789)"

Validate function is as follows:

function validate(field){
if(field.value== document.form1.myName.value){
if(document.form1.myName.value.length <= 1){
alert("Please enter name correctly, Name should be more than one character.");
document.form1.myName.focus();
return false;
}
}
}
Any help would be greatly appreciated.
Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: priti
Date: October 12, 2003 at 17:46:42 Pacific
Reply:

Never mind. I figured that out and now it's working properly.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Validation of entry in javascript

client side validation - javascript www.computing.net/answers/programming/client-side-validation-javascript/8811.html

Verify validity of a URL? www.computing.net/answers/programming/verify-validity-of-a-url/12081.html

Multiple key presses in JavaScript www.computing.net/answers/programming/multiple-key-presses-in-javascript/10927.html