/    Sign up×
Community /Pin to ProfileBookmark

uneditable text

Hi peeps
How do you make text uneditable. I have varibles set up in html, but would like to use java script to make sure that the user cant click in the txtbox and change the values
is it something like

document.pageName.variabeName.disable

any help would be very grateful

many thanks
b.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PittimannJul 23.2004 — Hi!

document.formName.fieldName.disabled

But that would have the consequence, that such a field's value would not be submitted on form submit. So it is better to use

document.formName.fieldName.readonly

Both of course can be easily tricked by simply disabling javascript; apart from that, some browsers do not "recognize" disabled or readonly. For such cases you could add some stuff to the tag itself:

<input type="text" name="blah" value="don't modify me" onfocus="this.blur()">

Cheers - Pit
Copy linkTweet thisAlerts:
@steelersfan88Jul 23.2004 — If you do not want it to be changed, why not use CSS to make an element the appearance of a text box.

To have it submitted, simply also include it as a hidden element.

Dr. Script
Copy linkTweet thisAlerts:
@PittimannJul 23.2004 — Hi!If you do not want it to be changed, why not use CSS to make an element the appearance of a text box.[/QUOTE]Hehe - that's of course much better. ?

Cheers - Pit
×

Success!

Help @bond spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...