Creating a Validation Object

Since we are validating user information, the JavaScript validation object that we are going to be creating will be called UserValidator. This object will have four methods: an initialize method for initializing all the object’s local variables; a setMode method, which sets the form mode from login to register; a validate method, which is the Ajax part that will make XHRs to a PHP object; and an onValidation method, which will be used as the callback method for the XHR and ultimately display the feedback to the user. When the object is created, it automatically calls the initialize method to set the local object variables. When a request is made, the validate method is called, which sets the onValidation method as ...

Get Ajax for Web Application Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.