I use ng-pattern="/0-9/"
to set price_field
do not accept decimal number
. But when I input natural number (from 0 to 9999999),ng-show
gets activated with Not valid number!
.
Where did I go wrong?. Please help.
<form name="myform" data-ng-submit="create()">
<input type="number"
name="price_field"
data-ng-model="price"
require
ng-pattern="/0-9/"
<span ng-show="myform.price_field.$error.pattern">Not valid number!</span>
<input type="submit" class="btn">
</form>
This is working
I made this for Vue developers. To highlight a way to do it with no regex
sideNote: Regex are a tremendous powerful tool you will always need it.
Writing that, the snipet below.
The problem is that your REGX pattern will only match the input "0-9".
To meet your requirement (0-9999999), you should rewrite your regx pattern:
My example:
HTML:
JS:
Here is a jsFiddle demo.
the following code will help for phone number validation and the respected directive is