javascript - Angular js TextField validation -
i working on angular js project, need validate data entered before submiting form.
<select class="form-control" id="offertype" ng-model="addoffer.discount"> <option value="buy x y free">buy x y free</option> <option value="basket level offer - 100$ 5">basket level offer - 100$ 5</option> <option value="basket level offer - product free">basket level offer - product free</option> <option value="discount %">discount %</option> <option value="discount $">discount $</option> </select> <input type="text" required class="form-control" id="" placeholder="enter discount value" ng-model="addoffer.value">
this select box (which select type of offer need given) , textfield (with sets value above selected offer).
when select buy x y free textfild should accept values x:y , x should greater y (e.g. 3:1) i.e. colon between 2 integers.
and rest of options inputfiled should accept integers. how validate textbox using angular js?
i guess directive should trick ! not sure how achieve this. kindly me. thannks in advance.
actually can have few text fields use different validation , ng-show
when corresponding option selected. imo having text field switches validation troublesome.
Comments
Post a Comment