Username Availability with an Asynchronous Validator in Angular - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Sunday, May 5, 2019

Username Availability with an Asynchronous Validator in Angular

A little while ago I released an article named Advanced Forms & Validation in Ionic where we discussed the concept of using Validators that Angular provides for validating form fields. These validators come in two flavours: synchronous and asynchronous. Synchronous validators can be used to perform simple synchronous checks like whether a field is empty, whether it exceeds a maximum length, or whether it matches a regex pattern. Asynchronous validators can perform more complex validations that can't be run synchronously, like hitting a server to check the availability of a username or email. If you do not understand the difference between synchronous and asynchronous code, I would recommend watching this video first. A form that uses this functionality might be built using Angular's FormBuilder like this: this.myForm = formBuilder.group({ firstName: ['value'], lastName: ['value', *validation function goes here*], age: ['value', *validation function goes here*, *asynchronous validation function goes here*] }); I've already explained most of how this works in the previous tutorial, however, a lot of people said that they had difficulty getting the validators to work when making a request to a real server (the previous tutorial just makes a "fake" asynchronous request to a server).


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


No comments:

Post a Comment