nam
nam

Reputation: 23789

Force user to use jquery datepicker

In my ASP.NET MVC 4 app, I am using the jquery.ui.datepicker.css to implement the datepicker for an input field as follows:

@Html.TextBox("txtDate", new { @class = "date", @title = "(mm/dd/yyyy)"})

When user clicks the textbox, the datepicker (calendar) popups where user can select a date. Some users just prefer to start typing the date instead. How can I force user to use the datepicker instead. I added the attribute @readonly = "readonly" into the textbox but the browsers then make the color of the textbox grayed out making user think that he/she cannot do anything there.

Please help.

Upvotes: 2

Views: 3998

Answers (1)

Yussuf S
Yussuf S

Reputation: 2112

I think you should add style="background:white;" to make looks like it is writable

<input type="text" id="txtDate" class="date" readonly="readonly" style="background:white;"/>

Upvotes: 8

Related Questions