Client side inline form validation using jQuery

Share:
There are two kinds of validations: client-side and server-side validation. It is recommended that you perform both.

Server Side Validation
In the Server Side Validation, the input submitted by the user is being sent to the server and validated using one of the server side languages such as ASP.Net, PHP, JAVA etc. After the validation process on the Server Side, the feedback is sent back to the client's web browser page.
Server side validation protect against the malicious users, who can easily bypass your Client Side scripting language and submit dangerous input to the server.

Client Side Validation

  • When you perform a Client Side Validation, all the user inputs validated in the user's browser itself. 
  • In tis validation you can provide a better user experience by responding quickly at the browser level. 
  • Client Side validation does not require a round trip to the server, so the network traffic which will help your server perform better. 
  • This type of validation is done on the browser side using scripting languages such as JavaScript or HTML5 attributes.


See the Pen Client side inline form validation by Sartaj Husain (@sartaj-husain) on CodePen.

Description:
  • We have used common class in span named with .error and placed above each field.
  • Created a Boolean function in JavaScript that will handle the validation.
  • We have used Regular expression to match the name because we want to validate name with only character and space.
The test() method used in Regular expression tests for a match in a string. This method returns true if it finds a match, otherwise it returns false.

Hi! I am Sartaj Husain. I am a Professional Software Developer, live in Delhi. I write blogs in my free time. I love to learn and share the knowledge with others because it is no good to try to stop knowledge from going forward. So free posts and tutorials. more..

No comments