Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


how to set a textbox readonly using javscript



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
sundarraj_mca



Joined: 14 May 2008
Posts: 17

PostPosted: Thu Jun 19, 2008 6:33 am    Post subject: how to set a textbox readonly using javscript Reply with quote

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
View user's profile Send private message Send e-mail
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 542
Location: Cebu City Philippines

PostPosted: Thu Jun 19, 2008 9:29 am    Post subject: Re: how to set a textbox readonly using javscript Reply with quote

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 Wink
Back to top
View user's profile Send private message Yahoo Messenger
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 542
Location: Cebu City Philippines

PostPosted: Thu Jun 19, 2008 12:11 pm    Post subject: Re: how to set a textbox readonly using javscript Reply with quote

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
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap