Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript validation that works both on client and Node.js server?

What are my options for using the same JavaScript code to validate both on client side and on server side (Node.js)?

like image 687
Sebastian Patten Avatar asked Nov 25 '11 21:11

Sebastian Patten


People also ask

Why do we do validation on both the client and the server sides?

Doing input validation on both the client side and server side has a number of benefits: It helps reduce server load since invalid data is never submitted in the first place. It helps prevent malicious users from submitting invalid data.

What type of validation is done on the server-side versus the client-side?

Validations can be performed on the server side or on the client side ( web browser). The user input validation take place on the Server Side during a post back session is called Server Side Validation and the user input validation take place on the Client Side (web browser) is called Client Side Validation.

Can we do server-side validation using JavaScript?

If by the above you understand moving validation to server side, then yes, it is definitely possible.

Is JavaScript used for client-side validation?

Scripting languages such as JavaScript and VBScript are used for client-side validation. In this kind of validation, all the user input validation is done in user's browser only.


1 Answers

Take a look at revalidator. It is described as "A cross-browser / node.js validator used by resourceful and flatiron."

like image 72
staackuser2 Avatar answered Oct 16 '22 17:10

staackuser2