Hai all ,
I had a from in a php page with 3 fields. ie username, name and email.
I have to do a form validation using javascript.
My code is like this.
<script language="javascript">
function Validate_form(){
if(document.getElementById('user_id').value.length<=5){
document.getElementById('user').className="error_msg2";
document.getElementById('user').innerHTML='Username must have minimum 6 chars.';
return false;
}
else{
document.getElementById('user').innerHTML='';
}
var emailfilter=/^.+@.+\..{2,3}$/
var returnval=emailfilter.test(document.getElementById('email').value);
if(returnval==false){
document.getElementById('email_msg').className="error_msg2";
document.getElementById('email_msg').innerHTML='Enter a valid email address';
return false;
}
return true;
}
</script>
But this code will check and give results of only one field at a time.
I need to display all the error messages together as ( appropriate innerHTML for each ) Please help me
Thanks
Rajeesh