I wrote a custom validator for jquery validator plugin .
Problem is, the custom validator I wrote is throwing error for anything I input. If I input plain text, it will still show error message.
I wrote a custom validator for jquery validator plugin .
Problem is, the custom validator I wrote is throwing error for anything I input. If I input plain text, it will still show error message.
Since it's a validator your function should return false
if the value
matches the regex
and true
if not:
$.validator.addMethod('noHTMLallowed', function(value) {
return !/<(.|\n)*?>/.test(value);
}, 'It contains HTML tags');