0

I'm trying to prevent non numeric userinput in an inputfield:

 <input ng-model-options="{allowInvalid: false}" ng-pattern="/^[0-9]*$/"
        class="cell large-3"  ng-model="val1" />

Unfortunatelly i can input also letters in the input. How I can change this behaviour?

1
  • Patterns usually don't prevent input, they just make it fail validation. Commented Jul 24, 2019 at 21:49

1 Answer 1

0

I'm trying to prevent non numeric userinput in an inputfield

Use type="number":

<script src="//unpkg.com/angular/angular.js"></script>
<body ng-app>
    <input type="number" ng-model="value" /><br>
    value={{value}}
</body>

For more information, see

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.