<script type='text/javascript' language="javascript">
function validate()
{
var error=0;
var name=document.getElementById("name");
var checkname =/^[a-zA-Z]+$/;
var email= document.getElementById("email");
var emailcheck = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
var re_pass;
if (name.value == "") {
name.style.background = 'Yellow';
error = 1;
alert('enter user name!');
} else if ((name.value.length < 5) || (name.value.length > 15)) {
name.style.background = 'Yellow';
error = 1;
alert('name must be between 5 and 15 characters!');
} else if (!checkname.test(name.value)) {
name.style.background = 'Yellow';
error = 1;
alert('invalid name! must be alphabet!');
} else {
name.style.background = 'White';
}
if (email.value == "") {
email.style.background = 'Yellow';
error = 1;
alert('enter email address!');
} else if (!emailcheck.test(email.value)) {
email.style.background = 'Yellow';
error = 1;
alert('invalid email address!');
} else {
email.style.background = 'White';
}
if (pass.value == "") {
pass.style.background = 'Yellow';
error =1;
alert('enter your passward!');
} else if ((pass.value.length < 4) || (fld.value.length > 15)) {
pass.style.background = 'Yellow';
error = 1;
alert('passwerd must be between 4 and 15 characters!');
}
if (re_pass.value == "") {
re_pass.style.background = 'Yellow';
error = 1;
alert('enter your passward again!');
}
else if(pass.value!=re_pass.value){
re_pass.style.background="yellow!";
error=1;
alert('both passward must be same!');
}
if(error=1)
return false;
else
return true;
}
</script>Inline Code Example Here
John_74 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.