Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validations of the input
Message
 
 
General information
Forum:
AngularJS
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01653867
Message ID:
01654028
Views:
61
I read now that article

https://www.yearofmoo.com/2014/09/taming-forms-in-angularjs-1-3.html

and also took a quick peak at the directive ng-remote-validation.

I think I'd like to create the directive myself and the examples in the article seem relatively straightforward, I hope to be able to follow them tomorrow but one thing I'm not exactly clear how to implement. Suppose my API call will return IsValid = false errorMessage = 'Some lengthy message'. I see in that article about setting validators, but I'm not clear about the validation message.

Thanks again.


>>>Why return an error - I'd just return true/false.
>>>
>>>ng-change should be ok but probably a good idea to add a debounce to the model options. Ideally something like:
ng-model-options="{ updateOn: 'default blur', debounce: {'default': 1000, 'blur': 0} }"
This would perform the check after 1sec. of inactivity, or immediately when the focus is moved.
>>
>>I'd like to return the message explaining where this barcode is already used (e.g. which item). Here is how I'd like the interface to look (see attached).
>>
>>So, as I understand it will involve setting the error (validation). This is the part I'm not 100% sure how to implement although I did a bit of research.
>>
>>https://stackoverflow.com/questions/16168355/angularjs-server-side-validation-and-client-side-forms
>>
>>There was a link in that discussion I planned to follow up but was very busy with other work. May be you have examples of how to do that part.
>>
>>Thanks.
>
>So have the server return a string describing the problem. I don't think you should (or need) treat a problem as an error.
>
>Two examples here (using directives) that might be worth looking at as an approach to client side handling:
>https://stackoverflow.com/questions/12864887/angularjs-integrating-with-server-side-validation
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform