-2

I started using jQuery validation on this new project I'm working on, and I've been struggling to find a rule to validate if a text input doesn't start "057" or "089" or "093.

I know there is a notEqual rule that matches the whole input value, is there any way I can achieve the same but only for the first 3 characters?

PaxBin
  • 111
  • 3
  • 14

1 Answers1

0

Try with something like that:

// Custom validation
$.validator.addMethod('customInput', function(value, element) {
    return this.optional(element) || /^(057|089|093)/.test(value);
});