By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

Text Object - Disable Typing

toxicpaint
P: 58
Hi there.

I have a text-entry object contained in a form which I'm using to describe pictures as I can write to it easily and it goes well with the look of the site.

I was jus wondernig if there was any way of disabling the user from typing into it without sticking "disabled" in the input tag because I'm using CSS to style the input box and althougbh it looks fine in Firefox, IE keeps the grey shadow as well as the CSS settings.

Does anyone know of a quick JavaScript to solve this?

Thanks!
Sep 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: 1
vin
Hi there.

I have a text-entry object contained in a form which I'm using to describe pictures as I can write to it easily and it goes well with the look of the site.

I was jus wondernig if there was any way of disabling the user from typing into it without sticking "disabled" in the input tag because I'm using CSS to style the input box and althougbh it looks fine in Firefox, IE keeps the grey shadow as well as the CSS settings.

Does anyone know of a quick JavaScript to solve this?

Thanks!
u culd use the key codes to restrict the input. in this way the style of ur inputbox wil remain the same n on key press nothin wil b entered to the input box. something like this u can do depending on wat all keys u want to restrict the user from entering them. this code wil restrict few keys like no space, no special characters like tht....

<input type="text" id="textbox" name="inputbox" onkeypress="if(event.keyCode < 48 || event.keyCode > 122) event.returnValue=false;if(event.keyCode > 57 && event.keyCode < 65) event.returnValue=false;if(event.keyCode > 90 && event.keyCode < 97) event.returnValue=false;">
Sep 29 '06 #2

toxicpaint
P: 58
That's pretty much what I want! Except I want to block EVERY keyboard entry so that they can't delete the text or backspace it or hit enter..
Sep 29 '06 #3

toxicpaint
P: 58
Can anyone help?

Here's what I'm working on, if it helps...

http://pcwww.liv.ac.uk/~tcowling/virtualtour
Oct 4 '06 #4

toxicpaint
P: 58
It's koay. The solution was to add "readonly/" into the input tag.
Oct 4 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.