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.
While I think that there are no "100% good guys" in this world (no country is), I do think that there are "less bad guys" or "preferred bad guys". From my personal POV, of course, I'd say that I prefer to side with Israel, the US and the Western world before siding with Iran, Hezbollah, Hamas, Russia, China and North Korea.
The "Western world" team has always been better regarding economics, freedoms and human rights than the "non-Western world" team. Israeli people have a degree of prosperity and freedom that Iranian, Russian and North Korean people could only dream about, that's a fact. The same applies to the "Western world" as a whole. Just look at the quality of life of the inhabitants of the "non-Western" world: it's measurably worst by any metric.
So that's why I choose to side with the West, every time. Results speak for themselves. Even if the West isn't perfect and 100% "good", either.
*lose
Anyway, had a feeling this was going to happen eventually which is why I started using NextDNS. The ad blocking on that is amazing (especially on android). It will be interesting to see how it works paired with ublock origin lite as I know the regular ublock origin extension removes a lot of ad placeholders
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