function verifyForm(){
var emailStatus = false;
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
if (document.getElementById('email').value.search(emailRegEx) == -1) {
emailStatus = false
alert("False");
}
else {
emailStatus = true;
alert("True");
}
return emailStatus;
}
Keeping it simple to start with I thought I'd start by validating one thing, that being the email address. I found the regex for email address's online. I am on a bit of a learning curve at the moment and appreciate the help you guys have been giving me.
I loaded the chrome console up and noticed that it said verifyForm was not defined. I've tried to load the js above using onlick for the time being to verify the code works.
I don't know why someone said useless, but it does have that pesky kernel driver bundled, and it's in perennial turmoil. When it goes bad, it goes very bad, and it's impossible to predict when it will due to system differences. I know that they're in the middle of development for a major new version that will include a completely new driver, one that they expect will largely solve the problem, but that's a ways out and it's unproven at this point.
Question
Axel
Trying to add some validation stuff to a web form using javascript:
http://jsfiddle.net/rGxP6/
function verifyForm(){ var emailStatus = false; var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; if (document.getElementById('email').value.search(emailRegEx) == -1) { emailStatus = false alert("False"); } else { emailStatus = true; alert("True"); } return emailStatus; }Keeping it simple to start with I thought I'd start by validating one thing, that being the email address. I found the regex for email address's online. I am on a bit of a learning curve at the moment and appreciate the help you guys have been giving me.
I loaded the chrome console up and noticed that it said verifyForm was not defined. I've tried to load the js above using onlick for the time being to verify the code works.
Here's the HTML:
I imagine as usual it's something simple I've overlooked!
Many thanks,
Alex
Edit: Off out for a bit shall return in an hour or so.
Link to comment
https://www.neowin.net/forum/topic/1133556-javascript-form-validation/Share on other sites
12 answers to this question
Recommended Posts