Click here to Skip to main content
15,886,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 3 textbox for first name, middle name and last name.... i want to make middle name readonly unless one doesn't input the 1st name in the text box. plz can anyone help me out??????
Posted

1 solution

You can manipulate the attribute readonly. Please see:
http://www.w3schools.com/tags/tag_input.asp[^],
http://www.w3schools.com/tags/att_input_readonly.asp[^].

For example:
JavaScript
document.getElementById("yourElementId").readOnly = true;


I would highly recommend using jQuery:
http://forums.asp.net/t/1702179.aspx?How+to+set+readonly+textbox+via+js+jquery[^],
for example: http://forums.asp.net/t/1702179.aspx?How+to+set+readonly+textbox+via+js+jquery[^].

—SA
 
Share this answer
 
v2
Comments
Member 10693938 24-Mar-14 3:08am    
actually m not using it in asp.net... i am using in html
Ankur\m/ 24-Mar-14 3:12am    
First two links still holds valid. Did you check them?
Sergey Alexandrovich Kryukov 24-Mar-14 3:14am    
Anything in this answer is valid. This is Javascript problem. I have no idea where OP managed to see ASP.NET.
Thank you.
—SA
Ankur\m/ 24-Mar-14 3:23am    
I am sorry I didn't check other two links. Still the point here is JavaScript provides a 'readOnly' property for elements on the page which can be used to toggle a controls read only attribute. Even I don't understand why it is not clear to the OP.
Sergey Alexandrovich Kryukov 24-Mar-14 11:01am    
Sure.
Thank you.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900