0

I have a form on my webpage that needs to make sure that the text a user is entering is in the proper format; however, it doesn't seem to be preventing the form submission when data of an incorrect format is entered. For example, the input needs to be a time of the format HH:MM am/pm and when I submit the form with a value of "a" in the field, it accepts the value when it shouldn't be.

Below is the code for the input:

<input id='timepicker' class="required" type='text' data-ng-model = "time" name='timepicker' pattern="(1[0-2]|[1-9]):[0-5][0-9](\\s)?(?i)(am|pm)" title="Time in HH:MM am/pm format" required>

Any help would be greatly appreciated

0

1 Answer 1

1

\s must not be escaped (it's not java), (?i) is not supported:

pattern="(1[0-2]|0?[1-9]):[0-5][0-9]\s?[aApP][mM]"
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.