How to block a record in the input text?

I just create a reservation system, and I want users to select a date from the calendar, and it will appear in the input text - what I did!

Now I want to block the entry in the input text (just cast the entry to the calendar there when the user selects a date). How can I do it? I think JavaScript, but how? I dont know js very wall ..

Many thanks!

+6
javascript
source share
2 answers
<input type="text" id="someId" disabled="disabled" /> 

A disabled property will prevent any user input, but you can still write it using your javascript calendar method.

+7
source share

Give your element the readonly attribute, this will prevent users from entering anything into it. However, you can still write to add via javascript, for example, when the date is selected. Here is an example:

 <input type="text" id="txt" readonly="readonly"> 

JavaScript:

 var el = document.getElementById('txt'); el.value = "Testing......"; 

Working demo

+23
source share

All Articles