Sisira 95

I have created a add email method (jquery) to validate a multiple emails for recipient text box. it's working fine when prototype.js is not declared on the page. To get rid of the $ conflict i also incorporated the $ noconflict() method measure measure. The other field validations are working in this scenario, except the receipient email validation field. AS per my finding "jQuery.validator.methods.email.call(this, value, element)" line no 50 of the page is not working and hence the method is not firing . I need to call the prototype.js as well. Please see the following code for a clearer understanding.......Thanks in advance.

HTML Code

See the HTML resource.

  • can we see some code, or better a link to a dev page? danwellman about 6 years ago
  • You can see and download the html detail code in the right side bar under resources heading Sisira about 6 years ago

1 answer

Sisira 95
0
points
This was chosen as the best answer

I have just change the approach a little bit, as jQuery.validator.methods.email.call(this, value, element) was not working in the previous custom method. Please give your suggestion if anySo I have added the following -

function validateEmail(field) {

var regex=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i;
return (regex.test(field)) ? true : false;

}

JQ.validator.addMethod("multiemail", function(value, element) {

var result = value.split(",");
for(var i = 0;i < result.length;i++)
if(!validateEmail(result[i]) || result.length > 5) 
return false;               
return true;                                                       

},'One or more email addresses are invalid');

Answered about 6 years ago by Sisira