Hi,
I have a date picker but i m trying the manual entry from user i-e September has 30 days how can i block 31st date to be manually entered from the user ???
Hi,
I have a date picker but i m trying the manual entry from user i-e September has 30 days how can i block 31st date to be manually entered from the user ???
jQuery UI has a DatePicker with all of this included.
why don't you give that a try, if possible?
You shouldn't get in the way when the user types something.
Instead you should do is: Let the user enter any value, validate it (that will fail), make the field red, add an error message above the form ("date is invalid"), set focus on the field.
Add a click handler to the submit button and make sure that all fields are valid. If one isn't, abort the submit (return false;). Otherwise return true; to submit the form.
You need to capture keyup event and prevent user from entering either invalid date which will require you to process what user have entered and is pretty difficult or you can just prevent anything to be entered by keyboard by using event.preventDefault(); so user will be able to select date from datepicker ONLY.
$("#mydatefield").keyup(function(e){
e.preventDefault();
});