Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting input to readonly using javascript

Status
Not open for further replies.

confused101

Programmer
Sep 14, 2010
3
US
thread216-1210105

I am setting input field to readonly based on certain value being passed on formload, the only problem I am having is the backspace button. If i click in the input field and use the backspace button it returns the previous form. I need the backspace button to backspace out characters in other fields on the form.

 
How are you setting the read only attribute?

And you can't backspace inside a read only input, because since its read only it can;t be modified.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Hi

Phil said:
And you can't backspace inside a read only input, because since its read only it can;t be modified.
He certainly can not. But in some browsers while the BackSpace press is not consumed as character deletion command, it bubbles forward and gets executed as BackSpace in the document itself == navigate backward || scroll up . That seems to be the OP's problem. ( BTW, I would do nothing. It is either browser behavior or user setting, so none of the webmaster's businesses. )

Feherke.
 
if(document.SLSHDB04.ADBTN.value == 'A')
{document.getElementById("CERT").readOnly = false;}
else{document.getElementById("CERT").readOnly = true; }

if(document.SLSHDB04.ADBTN.value == 'A')
{document.getElementById("CERTDT").readOnly = false;}
else{document.getElementById("CERTDT").readOnly = true; }

 
fehreke i can't access you link i don't have permissions.
thanks for your reply.

 
Hi

confused101 said:
fehreke i can't access you link i don't have permissions.
Ignore it. It is just part of my signature.

( Nothing to see there anyway, it is about shell scripting. But recently the server was reinstalled and is not fully configured yet. )

Feherke.
 
That looks o.k. but I agree with feherke (first time for everything I guess :p) Its likely just the default browser behavior for the backspace in a page. Since the element is read only it may be just accepting the backspace as the equivalent of the back button moving the page back.

Nothing really to do there I'm afraid except not backspace in a read only element.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top