- What is Validation?
- Why do we need both client-side and server-side validation?
How do web pages work?
You are the user visiting a web page and when you do visit a web page, you use the browser for that. You use your client, your machine, your laptop, or your computer, where you have a browser installed on it. You enter a URL or click on a search result on Google and the web page gets loaded. To be precise when you initially visit a web page, a request is sent to the server, so to a computer on the Internet where that web page, where the HTML file is hosted and that server then loads that web page and sends it back to your browser in a so-called response. The most basic form of response we know or we typically see and use when we work with the Internet when we visit a page is simply an HTML page that is sent back by the server to the client.
Now let’s say on that loaded web page, let’s say it’s an online shop, doesn’t really matter, the user clicks a button to submit a form, for example, to order some products. Now this will then trigger a new request which is sent by the browser to the server to send this form submission to the server and the server will handle the incoming request, maybe store some order data in a database and once it’s done, it will reply back with a new response, with a new web page, a new HTML document which is sent back to the client, maybe the order confirmation page.
How much do you know about the history of the most popular programming language?
1998 ECMAScript 2 is released.
ECMAScript5 was released in December 2009.
ECMAScript 4 never happened.
In 1995 Netscape made the best browser in the world and has received market dominance. So they thought of the browser/server combination as a new kind of distributed operating system. Browsers had the potential to let developers reach users on any platform such as Windows, Mac, or Linux .but the missing contents were a programming language. What Netscape wanted was a language to complement Java that would appeal to beginning programmers.
Netscape hired Eich in 1995 because they wanted him to create a programming language for that web browser.
They aimed to provide a “glue language” for the Web designers and programmers who were building Web content from components such as images, plugins, and Java applets. They found Java as the “component language” used by higher-priced programmers, where the glue programmers – the Web page designers – would assemble components and automate their interactions using JS.
- And then the machine code runs.
- Simple things are done easily.
- It’s supported by all browsers and enabled by default.
What is Validation?
It’s a process of testing and ensuring that data inserted by the user into an application are required and satisfy defined formats and other input criteria. So that only valid data can be submitted to a web application by the end-user.
Why do we need both client-side and server-side validation?
Validation can be performed either on the server-side or client-side (user browser).
- It works fast and is easier for the end-user.
- It is generally insecure as the user has easy access to the code of the page.
- It is used to reduce the errors that might come during server-side processing.
- It works very fast
- It minimizes the errors
- It has low security
For Example: If a user enters an invalid email address and moves to the next field, we can show the error message immediately right after, so that the user can correct the field before submitting the form. Whereas if we validate the same on the server, we have to submit the form to the server, the error message gets displayed, and then we can correct the wrongly entered field.
In server-side validation, all the input data validation and error recovery are carried out on the server-side i.e. user browser using programming language like C#.net, Java, etc.
- It works comparatively slower for the user.
- It is more secure as the end-user does not have easy access to the code.
- It is used to rescue any type of damage which can come during client-side validation.
- It has high security
- It is slow in execution. As every time request will be sent to the server for validation.
But we need to do both as the client-side gives an immediate validation response to user input without having to wait for the page to load. Whereas the server-side will always capture the validations which are not caught by the client-side validation.
*Try to always validate on the server.*
- Platform Independent.
- Easy to Learn.
- Increased interactivity: we can create an interface that reacts when the user interacts like hovering them with a mouse.
- Less Server Interaction: we can validate the user input before submitting the page to the server. This saves server traffic which means less load on the server.
- Immediate feedback to the user: we don’t have to wait for a page to load to check if any wrong data got entered.
- Chrome as a web browser + browser console to debug.
- Any text editor like Notepad /Notepad++
- Visual studio