0

I'd like to find a way to match the length of an input as well as the characters inside that input using javascript. Normally I'd just use the jquery plugin for validation, but for the client we can't use any 3rd party modules.

The input requires a string of characters between 6-13 but also does not allow the < or > characters within the values.

I'd like a way to check both the length of the string to make sure its between 6-13 but also reject the string if it contains < or >. I'm assuming this can be done with Regex, but my skills are severely lacking. The user should be able to see a message based on length and incorrect characters depending on what they are typing. Any quick methods out there?

1 Answer 1

1

or use this pattern

^(?!.*[<>]).{6,13}$  

Demo

^               beginning of line
(?!             Negative Look-Ahead
  .             Any character except line break
  *             (zero or more)(greedy)
  [<>]          Character Class [<>]
)               End of Negative Look-Ahead
.               Any character except line break
{6,13}$         (repeated {6,13} times) to the end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.