0

I am using the DatePicker plugin from jQuery and have set the minDate attribute. That works in the DatePicker-Popup, when clicking into the input field. But the user is still able to type in a date which isn't the range I want. Is their any way to avoid manual typing, force using the Datepicker or anything else? I am also using the validation Plugin, may be there is any way to combine that?

Thanks for help!

tecker2010
  • 11
  • 1

2 Answers2

1

You can make the datepicker textbox readonly. Show the datepicker. Then every user has to choose from datepicker.

<input type ="text" readonly />

Or you can put a button near the textbox to show the datepicker.

sudhansu63
  • 6,025
  • 4
  • 39
  • 52
0

Thanks. The datePicker function provides attributes for using an icon-trigger, which I didnt't know. With that, you can force users to fill in a date only when clicking on that image.

In my case, I found a validation rule for dates. With that rule and the icon-trigger, everything works like a charme.

I am using the following validation rule for dates like dd.mm.yyyy:

$.validator.addMethod("datum", function (value, element) {
       return this.optional(element) || /^(?:(0[1-9]|[12][0-9]|3[01])[\/.](0[1-9]|1[012])[\/.](19|20)[0-9]{2})$/.test(value);
    }, "Datumsformat ungültig.");

Best regards.

tecker2010
  • 11
  • 1