- Understanding ECMAScript.
- What is Validation?
- Why do we need both client-side and server-side validation?
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.
We are at ECMAScript 6 (Officially: ECMAScript 2015), also known as ES6.
In 1995 Netscape made the best browser in the world and has received market dominance. So they thought 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.
- used to insert dynamic text into the HTML (ex: Name, Address, etc.)
- react to events (for example, load the page only when the user click on a button)
- It also used to perform some calculations on the user’s machine such as validating the user input.
- Animated/dynamic drop-down menus
- Displaying clock, date, and time.
- Get and set cookies, ask questions to the visitor, show messages.
- Remember the data/info on the client-side (“local storage”).
Client-Side scripting, means the ability to manipulate data, the DOM, and a webpage as a whole, without having a backend service or language.
We can make calculations, validate a form or any input field, include some logic that runs when a condition is met, also can manipulate the webpage, and add a lot of functions to a website without any SS (Server-Side) language.
- The Core(ECMAScript)
- The Document Object Model(DOM)
- The Browser Object Model(BOM)
ECMAScript is simply a description, defining all the properties, methods, and objects of scripting language.
- Data Types
- Reserved Words
Each browser has its own implementation of the ECMAScript interface, which is then extended to contain the DOM and BOM. Today, all popular web browsers comply with the 3rd edition of ECMA.
- DOM (we will discuss later)
- BOM (we will discuss later)
- V8 – in Chrome and Opera.
- SpiderMonkey – in Firefox.
- “Chakra” for IE, “ChakraCore” for Microsoft Edge, etc.
- And then the machine code runs.
- Simple’s 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 satisfies 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 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 move 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 to display, 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 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 that 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