jQuery Attach handler for validation -
i need field validation(required field) using jquery. using existing jquery code(3rd party). current scenario: input control name input control phone(required, regex) input control email(required, regex) here passing div id , 3rd party code loop through child elements , validation , returns true if pas else false.(no validation message)
but regex have mentioned
function validateusingregularexpression() { // construct jquery object out of element changed. var $element = jquery(this); var validatesuccess = false; var value = $element.val(); //do regex validation if returns true set validatesucess = true; triggerresult(validatesuccess, $element); } function triggerresult(validatesuccess, $element) { if (validatesuccess) { $events.trigger('validatorsuccess', [$element]); } else {`enter code here` // if 1 validation fails fails group. me.isvalid = false; var message = $element.attr('regex failed'); $events.trigger('validatorfailure', [$element, message]); } } // attach custom event handling requiredfieldvalidator exception if default behavior // not adequate. this.onvalidatorsuccess = function (handler) { $events.on ('validatorsuccess', handler); } this.offvalidatorsuccess = function (handler) { $events.off('validatorsuccess', handler); } this.onvalidatorfailure = function (handler) { $events.on('validatorfailure', handler); } this.offvalidatorfailure = function (handler) { $events.off('validatorfailure', handler); }
can 1 please me how add handler
Comments
Post a Comment