Validating date in asp net
We add the following script in the Index.cshtml to add Date Pickers for the Start Date and End Date inputs boxes.This will give us Date Pickers for the Date Fields We are all set with our harness now, let’s build the custom date validator.
There is a nasty bug in j Query UI’s date picker, so we’ll see how we can fix that as well using another Java Script library Throw in the weird Date format that MVC returns and you will end up tearing out your hair in frustration with Date. It has a single Home Controller that has the Index Action Method.
So I thought why not writing a post which validates the date as well. Well, I have created a function which takes date value as input and returns true/false based on date validation logic. I believe life is short, and it is for loving, sharing, learning and connecting.
Below is the j Query function which validates the date.
There are four distinct parts to creating a fully functional custom validator that works on both the client and the server.
First we subclass Validation Attribute and add our server side validation logic.