Just ina case you didn't know: that regex won't strictly 'validate' email addresses. You might wish to read this, or Google for some info on the near inability to actually do so.
function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }
However I havn't figured how o tie it into the existing PageValidateText routine and work.
Doesn't the if(validateEmail('[email protected]')) works? That should return true. Else try and make an alert in the validateEmail method and see what re.test(email) returns.
Regex validation on Email address...
Hi Guys.
I have found the section in your simple.js file to check for null values in the checkout page
if (formObj.email === '') {
pageValidateText += '\nE-mail';
}
How could I mod this to check for a valid email. I'd want to use a regex expression like this to validate:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Thanks.
Hi Streety
This might help you: http://www.regular-expressions.info/javascript.html
Kind regards
Anders
Thanks for that Anders.
Please forgive my JS. Something like this?
var valid_email = new RegExp("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
if (formObj.email.match(valid_email)) {
alert(
"Successful match");
}
else {
alert(
"No match");
}
Doesn't work though.
Just ina case you didn't know: that regex won't strictly 'validate' email addresses. You might wish to read this, or Google for some info on the near inability to actually do so.
Hmmm. Wondered why such a basic function is missing from the sample website.
The validation of email and postcodes is rather bread & butter wouldn't you say?
I am a little further forward with this:
I have a functional called Validate that can check the input string on the email input.
However I havn't figured how o tie it into the existing PageValidateText routine and work.
Any support would be greatly received.
Doesn't the if(validateEmail('[email protected]')) works? That should return true. Else try and make an alert in the validateEmail method and see what re.test(email) returns.
Kind regards
Anders
Yes the method works however I can't seem to wire in to your pagevalidattext statement.
This checks to see if any validation message have been posted and it not, allows the process to continue.
if
(pageValidateText != '') {
I want to able to use the existing frame to add a new validation message "bad email" to the pagevalidationtext
var pageValidateText = '';
This html editor on this forum is so pants.
Cant you just make something like this in the teaCommerce_Simple.js
if (!validateEmail()) {
pageValidateText += '\nBad email!!';
}
Kind regards
Anders
is working on a reply...