JavaScript is a dynamic programming language. It is most commonly used
as part of web browsers, whose implementations allow client-side scripts to
interact with the user, control the browser, communicate asynchronously, and
alter the document content that is displayed.
Advantages of using JavaScript
Ø Form validation can be done on the client side, which reduces the
unnecessary round trips between the client and the server. This also means the
load on the server is reduced and the application is more responsive.
Ø JavaScript uses the client machine processing power.
Ø With JavaScript partial page updates are possible i.e only
portions of the page can be updated, without reloading the entire web form.
This is commonly called as AJAX.
Ø JavaScript can also be used to animate elements on a page. For
example, show or hide elements and sections of the page.
Disadvantages of JavaScript
Ø Security: JavaScript runs on the client machine. So a malicious
user may use JavaScript to do a variety of things like tracking your browsing
history, stealing passwords etc. This is one of the main reasons why people
disable JavaScript.
Ø Browser Compatibility: Not all browsers treat the same piece of
JavaScript in the same manner. This means the functionality and the user
interface may vary from browser to browser. That is why cross-browser testing
is very important. However, with JavaScript libraries like jQuery Browser
Compatibility is no longer a major issue.
Why Client side and Server side validation require?
If
we have disabled JavaScript, then it will bypass the client side validation and
we also don't have any server side method validating the form. This is one of
the reasons why we always want to have both client side and server side
validation.
If
JavaScript is disabled and if we don't have any server side validation, there
could be different threats ranging from storing invalid data to security
vulnerabilities.
Client-side
validation provides better user experience as it reduces the unnecessary round
trips between the client and the server. So client side validation is nice to
have.
However,
if JavaScript is disabled or if the user is making a request using tools like
fiddler we still want to validate the form before saving data. So, server side
validation should always be there irrespective of whether we have client side
validation or not.
Comments
Post a Comment