Open dilipjain opened 9 years ago
I suspect this can be handled with a custom validator - I will look and see if I can post an example...
Did you got chance for a custom validator sample. I have couple of other fields which I can need to add custom validation.
Hi dilipjain,
Apologies for the delay in responding - if you're still looking for an example, give this a try (it's based off a patch submitted for approval in this repo):
$.tools.validator.fn("[type=email2]", "Please supply a valid email address for me", function(input, value) {
return !/^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,63})$/i.test(value);
});
$("#myform").validator();
I should point out something - the "email2" is not standard; this is because the plugin doesn't allow me to override the regex that is already included for emails. I would suggest renaming this to something like "userEmail", so it makes sense?
EDIT: Just noticed that the regex would fail, due it it checking too short a TLD; I've updated it...
I will be looking to update the inbuilt regex within the library, once I get the next version released...
Actually original regex doesn't contain leading exclamation mark so to make this behave well with the rest of code you should remove it. Other than this, good idea. Worked well for me!
The tools validator does not recognize new top level domains in email address e.g. sales@musiceducation.directory