It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Partner Sites
Board index Programming JavaScript Forum

how to set a textbox readonly using javscript

how to set a textbox readonly using javscript

Postby sundarraj_mca on Thu Jun 19, 2008 6:33 am

hai developers

i am wondering how to set a textbox property as readonly using javascript could get me a solution for this

bye
sundarraj_mca
 
Posts: 22
Joined: Wed May 14, 2008 6:06 am

Postby rangana on Thu Jun 19, 2008 9:29 am

You can use the readonly attribute, and access the input type you wish:
Code: Select all
<script type="text/javascript">
window.onload=function()
{document.getElementById('myinput').readOnly='readonly';}
</script>
<input type="text" id="myinput" value="test">


Hope it helps ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 6:14 am
Location: Cebu City Philippines

Re: how to set a textbox readonly using javscript

Postby rangana on Thu Jun 19, 2008 12:11 pm

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.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 6:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 13 guests