I need not to allow only characters to my input field and want to check the validation using Angular.js. My code is below.
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right oditek-form" style="width:180px">Longitude:</span>
<div ng-class="{ 'myError': billdata.longitude.$touched && billdata.longitude.$invalid }">
<input type="text" name="longitude" id="longitude" class="form-control oditek-form" placeholder="Add Longitude coordinate" ng-model="longitude" ng-pattern="/^[0-9]+([,.][0-9]+)?$/" ng-keypress="clearField('businessno');" >
</div>
<span class="input-group-btn">
<a ui-sref="dashboard.customer.view" class="btn btn-success" style="height:30px;" title="Click Here" ng-click="getLongValue();"><i class="fa fa-map-marker" aria-hidden="true"></i></a>
</span>
</div>
In the above code I have set also some regular expression into ng-pattern
but its not allowing the number like -12.345,+2.345 etc
. Here I need this field will only allow numbers('ie-1,2...9'),special character like ( only +, -, . etc
).
ng-pattern
这种模式应匹配:
ng-pattern="/^[0-9,\.\-\+]+$/"
可能是ng-pattern =“/ [0-9,\\ W] / g”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.