1

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.

0

1 Answer 1

1

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');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.