Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ASP.NET Core 2 Fundamentals

You're reading from   ASP.NET Core 2 Fundamentals Build cross-platform apps and dynamic web services with this server-side web application framework

Arrow left icon
Product type Book
Published in Aug 2018
Publisher
ISBN-13 9781789538915
Pages 298 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Onur Gumus Onur Gumus
Author Profile Icon Onur Gumus
Onur Gumus
Mugilan T. S. Ragupathi Mugilan T. S. Ragupathi
Author Profile Icon Mugilan T. S. Ragupathi
Mugilan T. S. Ragupathi
Arrow right icon
View More author details
Toc

Client-Side Validation


There are scenarios where we don't need to go to the server to validate the input data. In the preceding example of server-side validation, we do not need to go to the server to verify whether the user has entered the data for the Name field. We can validate at the client side itself. This prevents round-trips to the server and reduces the server load.

We are going to use JavaScript to validate the data from the client side. JavaScript is a high-level, interpreted language that is primarily used in client-side programming.

Note

At present, JavaScript is also being used at the server side as part of Node.js.

Performing Client-Side Validation

Follow these steps to perform client-side validation:

  1. We are going to make a couple of changes in our ViewModel (the Index.cshtml file) to validate the form at the client side:
    1. Changes in the form: add the id attribute to all the span tags so that we can access this HTML element to display the HTML error message. On submission of the...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime