Mark Estrada
Mark Estrada

Reputation: 9201

Only allow Datepicker Button Jquery UI

Is it possible to disable the input textbox at which I attached my datepicker and only allow input by clicking the button/icon panel of the Jquery UI datepicker.

$(function(){
    var opt = {
        buttonImage: "images/cal.png",
        buttonImageOnly: true
    };
    $("#date").datepicker(opt);
});

What I mean is, the icon is there but user could still type in an invalid date. Say my format is "mm/dd/yyyy", but I could just type in and set it to 16/10/2010.

I used the jquery validation and jquery masked input plugin in conjunction but they still accept both value.

I dont want my server side code to catch up this but rather I wanted to trap it using javascript as much as possible although I setup a checking on my Spring MVC also.

Is this possible? Thanks

Upvotes: 0

Views: 1373

Answers (2)

Srđan Janjić
Srđan Janjić

Reputation: 9

In XHTML, attribute minimization is forbidden, and the readonly attribute must be defined as <input readonly="readonly" />.

Upvotes: -1

CristiC
CristiC

Reputation: 22708

You can make your input textbox readonly.

Upvotes: 2

Related Questions