0

I am new to angularJs and currently working on a form validation.

Below is the snapshot of the form:

enter image description here

Task: is to validate the Qty values. Field SX and Qty exist in DB. I am using a webservice on ng-blur of SX and Qty to get the max(Qty) value from the DB table. If the current Qty value is greater than the max(Qty) value of DB table then it should show an OK/Cancel Message box. If Ok it will submit the data to DB and if Cancel it will reset the current value.

Since I am calling the web service on ng-blur, it working perfectly fine when Submit button is clicked but its not working when Enter is clicked.

My question is how to validate my SX and Qty values both on ng-enter and button click i.e. ng-click where I am calling addItems()?

Also, when I click on the Submit button and if there is any validation there then only the ng-blur function is getting called, I have to click again to call the addItems(). I want this in single click.

Any immediate suggestions will do a great help.

slavoo
  • 5,798
  • 64
  • 37
  • 39
user340241
  • 13
  • 3
  • 1
    Give us your code, we don't know where this `addItems` is being called. If you're using `` tags you can use `ng-change` as well as `ng-blur` to trigger on it enter – floribon Sep 16 '16 at 09:24
  • @floribon: ng-blur is not trigggering on ng-enter and ng-click doesn't get triggered if ng-blur is used. I have to click on Submit button twice if there is validation. I am calling addItems() on ng-click and ng-enter. Does ng-change get triggered in both ng-enter and ng-click? – user340241 Sep 16 '16 at 10:02
  • refer this http://jsfiddle.net/82PX4/3/ you will get a idea source http://stackoverflow.com/questions/12044277/how-to-validate-inputs-dynamically-created-using-ng-repeat-ng-show-angular – balajivaishnav Sep 16 '16 at 10:46
  • @MBalajivaishnav: I have already referred these files. It doesn't work for me because here normal validations are being done. But i my program i have to call a web service to validate the data. If every thing is being done in the click event its working fine but it fails when i am using ng-enter because the ng-blur event is not getting fired. I just want to call the same function for the current row values of ng-repeat control for validation as I am already validating the other rows on ng-blur. – user340241 Sep 16 '16 at 11:50
  • can u make a plunkr with your code will be easy to resolve the issue for all – balajivaishnav Sep 16 '16 at 11:54
  • @MBalajivaishnav: How can i call my backend wcf web service using plunkr? Values are coming from DB using wcf services. I can only paste code snapshot. – user340241 Sep 16 '16 at 12:06
  • actually the validation part are not coming from web service right, your problem is need to validate the dynamic fields so post that part only – balajivaishnav Sep 16 '16 at 12:07

0 Answers0