Hi all
I am hoping for some help on my form.
I would like to validate email field and a phone field.
currently the validation only checks if the fields have been left blank.
I would like to change it to a simple email validation that checks for a valid email adresss (simple is fine as (I know this can get technical) and the phone number to accept only numbers.
below is what I am using now
email:
var email = $("input#email").val();
if (email == "") {
$("label#email_error").show();
$("input#email").focus();
return false;
}
so instead of checking if the field is blank, I'd like to be able to check if the field IS NOT VALID, and then show error msg (which is defined elsewhere)
and the phone is here
var hphone = $("input#hphone").val();
if (hphone == "") {
$("label#hphone_error").show();
$("input#hphone").focus();
return false;
}
Now please note that I am not that familiar with javascript as I only "get my hands dirty" when I absolutely need to and apply some simple scripts I find on the net, so if your answer is very c0omplex it will go over my head.
Thanks in advance
Sami
I am hoping for some help on my form.
I would like to validate email field and a phone field.
currently the validation only checks if the fields have been left blank.
I would like to change it to a simple email validation that checks for a valid email adresss (simple is fine as (I know this can get technical) and the phone number to accept only numbers.
below is what I am using now
email:
var email = $("input#email").val();
if (email == "") {
$("label#email_error").show();
$("input#email").focus();
return false;
}
so instead of checking if the field is blank, I'd like to be able to check if the field IS NOT VALID, and then show error msg (which is defined elsewhere)
and the phone is here
var hphone = $("input#hphone").val();
if (hphone == "") {
$("label#hphone_error").show();
$("input#hphone").focus();
return false;
}
Now please note that I am not that familiar with javascript as I only "get my hands dirty" when I absolutely need to and apply some simple scripts I find on the net, so if your answer is very c0omplex it will go over my head.
Thanks in advance
Sami