I have used http://www.dynamicdrive.com/dynamici...uiredcheck.htm
to successfully validate parts of my form, just wondering if I could get some assistance in validating other functions such as valid email and is numeric?
Thanks
I have used http://www.dynamicdrive.com/dynamici...uiredcheck.htm
to successfully validate parts of my form, just wondering if I could get some assistance in validating other functions such as valid email and is numeric?
Thanks
For the email check, you could combine the script above with the following one:
http://www.dynamicdrive.com/dynamicindex16/emailvalidate.htm
As for the numbers, I believe there is a function call isNaN (is Not a Number). But not 100% on that.
Hope this helps.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
Here is my email validation function:
And for the numeric, as thetestingsite said, there is isNaN function in javascript:Code:function echeck(str) { var at = "@" var dot = "." var lat = str.indexOf(at) var lstr = str.length var ldot = str.indexOf(dot) if (str.indexOf(at) == -1){ alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail ID") return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1){ alert("Invalid E-mail ID") return false } return true }
Code:if(isNaN(value)){ alert('string'); }else{ alert('numeric'); }
Bookmarks