tags:

views:

28

answers:

2

Hello!

I just creating a booking system and I want that the users will choose a date from the calender and it'll show in input text - that I did!

Now I want to block the writing in the input text (just bring to calender writes there when the user choose a date). How do I do it? I guess JavaScript, but how? I dont know JS very wall..

Thank you very much!

+2  A: 
<input type="text" id="someId" disabled="disabled" />

The disabled property will prevent any user input, but you can still write to it via your javascript calendar method.

Marko
Thank you! Luis.
Luis
+1  A: 

Give your element the readonly attribute, this will disallow users to type anything into it. However, you will still be able to write to add through javascript for example when a date is chosen. Here is an example:

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

JavaScript:

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

Working Demo

Sarfraz
The BEST! thank
Luis
@Luis: You are welcome...
Sarfraz