4 Replies - 3208 Views - Last Post: 20 January 2009 - 10:29 AM

#1 animedude123  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 03-August 07

Disable part of a textbox?

Posted 19 January 2009 - 11:21 PM

Hey,

I was wondering if there was a way to have a textbox with default text like "Hello," and have it so that "Hello," is "disabled" in the sense that it can't be edited, though still allow the user to addon to that.

My guess is it would have to be done with javascript, which is why I put it here. If it isn't possible, is there something else that would produce a similar result?

Thanks for any help!

Is This A Good Question/Topic? 0
  • +

Replies To: Disable part of a textbox?

#2 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Disable part of a textbox?

Posted 20 January 2009 - 06:33 AM

No, there is no way to accomplish what you are asking.

One possible work-around is to have the text you wish to remain unchanged as a label for a text box which the user is able to edit (like blank spaces in a sentence). Or you could have some javascript automatically append the "static" text to whatever the user enters.
Was This Post Helpful? 0
  • +
  • -

#3 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1167
  • View blog
  • Posts: 7,207
  • Joined: 07-September 06

Re: Disable part of a textbox?

Posted 20 January 2009 - 06:34 AM

I don't think you can disable part of a textbox. What you may want to try instead is to place the original text in a div before the textbox and then have the textbox open to anything you type, so that it looks something like this:

<div>Hello </div><textarea>User input text</textarea>


Hope that makes sense.
Was This Post Helpful? 0
  • +
  • -

#4 animedude123  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 80
  • Joined: 03-August 07

Re: Disable part of a textbox?

Posted 20 January 2009 - 10:22 AM

Ok, thanks. I figured as much (I'd never seen an example of what I was asking)

I'll just have the static text posted outside the textbox.
Was This Post Helpful? 0
  • +
  • -

#5 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Disable part of a textbox?

Posted 20 January 2009 - 10:29 AM

Actually the more I think about it, it is sort of possible. You could have a div that wraps both the label element and the input and use css to control how the text area and label are displayed so it would "look like" it was all in the same input box. A lot of extra work IMNSHO
<div style="border:1px solid gray; color:#999999; font-family:arial; font-size:10pt; width:200px; white-space:nowrap;">
Hello
<input type="text" style="border:0px solid black;">
</div>

This post has been edited by xerxes333: 20 January 2009 - 10:44 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1