<input type="text" ng-model="price" name="price_field" ng-pattern="/^-?[0-99]+(.[0-99]{0,2})?$/" required>
if text box value preceed with .(dot) it should append 0(Zero) for example: .50 => result should be 0.50 also if it is 5. it should be 5.0
if text box value preceed with .(dot) it sh" /> if text box value preceed with .(dot) it sh" /> if text box value preceed with .(dot) it sh"/>
<input type="text" ng-model="price" name="price_field" ng-pattern="/^-?[0-99]+(.[0-99]{0,2})?$/" required>
if text box value preceed with .(dot) it should append 0(Zero) for example: .50 => result should be 0.50 also if it is 5. it should be 5.0
Copyright © 2021 Jogjafile Inc.
ng-pattern="/^-?([0-9]{0,2})+(.[0-9]{0,2})?$/" Use this pattern which will allow .5 and 5. You have to have some kind of solution to handle this number in backend .ng pattern cant convert .5 to 0.5. you can use Number funtion to achive this .