user input box: first 2 characters as a read only value

R

reneeccwest

<input type="text" size="7" name="test" maxlength="4" value="4Tyourname">

Is there any way I can make first 2 characters as a read only value?
 
V

Vjekoslav Begovic

reneeccwest said:
<input type="text" size="7" name="test" maxlength="4" value="4Tyourname">

Is there any way I can make first 2 characters as a read only value?

Of course not, but you could simulate that strange behaviour, something like
this:

<input value="4T" size="2" style="margin-right:none; border-right:none;
text-align:right;"
onfocus="document.getElementById('yourname').focus()"><input id="yourname"
style="margin-left:none; border-left:none" value="yourname">
 
G

Grant Wagner

reneeccwest said:
<input type="text" size="7" name="test" maxlength="4" value="4Tyourname">

Is there any way I can make first 2 characters as a read only value?

If it really is read-only, then make it read-only:

<style type="text/css">
span.outline {
font-family: monospace;
border: 2px inset;
}
@media screen,print {
span.outline {
padding: 1px;
}
input.noBorder {
font-family: monospace;
border: none;
}
}
</style>
<form>
<input type="hidden" name="testHidden" value="4T">
<span class="outline">4T<input type="text" size="9" name="test" maxlength="8"
value="yourname" class="noBorder"></span>
</form>

When the submitted data arrives at the server, concatenate the contents of
testHidden and test together.

Of course it doesn't look so hot in Netscape 4.x, but it's not completely
unusable, and in more modern browsers you get a funky input box where the
first two characters appear to be "read-only". The only browser I'm really
disappointed at is Opera 7.11. It refuses to honor border:none on the input
element.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
R

reneeccwest

Is it possible to remove the space from the left side?
There is a space before "4T"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,219
Latest member
Geraldine7

Latest Threads

Top