tags:

views:

36

answers:

3

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 ???

A: 

jQuery UI has a DatePicker with all of this included.

why don't you give that a try, if possible?

balexandre
Is something possible like this "valid number" for date ???
+1  A: 

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.

Aaron Digulla
I'm curious to know why you think this can't be done.
Justin Johnson
Improved wording to make my point more clear.
Aaron Digulla
it might be good approach where some browsers might cause trouble for rendering particular datepicker in this case you have to revert back to user entering date manually.
Ayaz Alavi
Entering the date manually is sometimes much faster. Think of a "Date of birth". If you were born 1980, then you have to click 30 times to get the right year!
Aaron Digulla
+1  A: 

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();
});
Ayaz Alavi