473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

<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?
Jul 20 '05 #1
3 7229
"reneeccwest" <re*********@hotmail.com> wrote in message
news:9f**************************@posting.google.c om...
<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">
Jul 20 '05 #2
reneeccwest wrote:
<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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #3
Is it possible to remove the space from the left side?
There is a space before "4T"

"Vjekoslav Begovic" <vj*******@inet.hr> wrote in message
news:bj**********@sunce.iskon.hr...
"reneeccwest" <re*********@hotmail.com> wrote in message
news:9f**************************@posting.google.c om...
<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">

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: reneeccwest | last post by:
Different user input boxes are automatically populated based on a value of the dropdown box. Can anyone help me on that?
9
by: refer_to_website | last post by:
My VB.NET web application has a textbox where the user is allowed to enter up to 50 characters. I have a label on the form next to the textbox that tells the user how many remaining characters he...
4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
2
by: der | last post by:
Hello all, I want to use fgets() to read lines. Now, if the user has entered more characters than it was supposed to, the next call to fgets() would read these characters, which I don't want to...
4
by: santa19992000 | last post by:
can I use scanf to get input (some times user enters input sometimes not, just hit keyboard)?. It displays to enter IP address, if user wants to change, then he enters, otherwise he hits keyboard,...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
2
by: Rajen | last post by:
Suppose the field length is 25 characters. After entering the 25th character, it should be available to process. Program should not wait for the user to press enter/return key. Thank you.
1
by: kang jia | last post by:
hi when user entered particulars in signuppage and click" signup" button, i will direct them to do_signup.php. if say the NRIC is dupicate in datebase, i will redirect them back to signup page...
14
by: n3o | last post by:
Hello Comp.Lang.C Members, I have an issue with user input that I have been trying to figure out for the longest. For instance, let's say you have something like this: void foo() { int num;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.