0

So I have an input form in Angular here:

<input ng-model="sc.zip" class="form-control" maxlength="5" type="text" /> 

I don't want type="numbers" because the form needs to be a plain empty textbox. However, I only want the user to be able to type numbers. Either I need to detect when the input is not a digit, or be able to search through the box to find non-digits when submitting.

Either way, I need to validate that the form is digits only. Any help would be appreciated!

2

1 Answer 1

1

use regex

 <input name="title" type="text" ng-model="sc.zip" ng-pattern="/^[0-9]*$/" required/> 
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.