| View previous topic :: View next topic |
| Author |
Message |
sundarraj_mca
Joined: 14 May 2008 Posts: 19
|
Posted: Thu Jun 19, 2008 6:33 am Post subject: how to set a textbox readonly using javscript |
|
|
hai developers
i am wondering how to set a textbox property as readonly using javascript could get me a solution for this
bye |
|
| Back to top |
|
 |
|
|
rangana 500+ Club

Joined: 27 Feb 2008 Posts: 718 Location: Cebu City Philippines
|
Posted: Thu Jun 19, 2008 9:29 am Post subject: Re: how to set a textbox readonly using javscript |
|
|
You can use the readonly attribute, and access the input type you wish:
| Code: |
<script type="text/javascript">
window.onload=function()
{document.getElementById('myinput').readOnly='readonly';}
</script>
<input type="text" id="myinput" value="test">
|
Hope it helps  |
|
| Back to top |
|
 |
rangana 500+ Club

Joined: 27 Feb 2008 Posts: 718 Location: Cebu City Philippines
|
Posted: Thu Jun 19, 2008 12:11 pm Post subject: Re: how to set a textbox readonly using javscript |
|
|
| sundarraj_mca wrote: |
hai rangana,
i have a problem with my web page since i am using a form in it which has javascript for data manuplating, i use a submit button. if i disable it the whole form parameters gets disabled in IE and not works properly in other browsers. so when i click this submit button form should be submitted if all fields are correct else return to same page.
can you rectify this to me
thank you
|
Originally sent via PM.
Ideally, you can have all the input elements inside the form to have a readonly attribute using JS.
For the submit stuff, you can have an onsubmit event handler which will return true if all the fields are correct, if not, then it shall return false.
If that ain't help, show us the whole code and we'll be glad to help you.
Also, please use the public forum, some members might have exactly the same problem as yours. |
|
| Back to top |
|
 |
|