Hello,
is there a possibility to apply a validation to multiple fields?
In my example there are several email fields. But since I don't want to store the same validation for each field, I thought to solve the whole thing using an array.
Is there such a possibility?
Here is my code. I know that emailArray.addValidator don´t work.
var emailArray = ['E_x002d_mail_x0020__x0028_invoic', 'E_x002d_Mail_x0020_Dunning_x0020', 'CP_x003a__x0020_E_x002d_Mail_x00', 'CP_x003a__x0020_E_x002d_mail_x000']; emailArray.addValidator({ name: 'Check Email', error: 'Enter a correct E-Mail', validate:function(value){ var Reg = new RegExp(/([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/); for(i=0; i< emailArray.length; i++){ if(Reg.test(emailArray[i])){ return true } return false; } } });
I hope you can help me fixing my problem.