Connecting Tech Pros Worldwide Help | Site Map

Input box match

Member
 
Join Date: Oct 2007
Posts: 70
#1: Dec 5 '07
Hi all,

I wanted to find out something.
If you have an input box on an html form and you wanted it to operate as follows.
It will be used to enter a phone number with no dashes. The phone number can have 10,11,even 15 digits(different parts of the world).
I wanted the input box to have the digits 1868 in the beginning of the box and let the curser be after the last 8 digit when the box gets focus so that the user could enter the other numbers after 1868 for local calls.Otherwise, The user could press backspace and delete the 1868 digits for international calls and type the entire international call number.

Is this possible at all?
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,566
#2: Dec 5 '07

re: Input box match


Quote:

Originally Posted by phpmel

Hi all,

I wanted to find out something.
If you have an input box on an html form and you wanted it to operate as follows.
It will be used to enter a phone number with no dashes. The phone number can have 10,11,even 15 digits(different parts of the world).
I wanted the input box to have the digits 1868 in the beginning of the box and let the curser be after the last 8 digit when the box gets focus so that the user could enter the other numbers after 1868 for local calls.Otherwise, The user could press backspace and delete the 1868 digits for international calls and type the entire international call number.

Is this possible at all?

Well, one thing you could do is give your input box a pre-defined "value" using the value option to the input tag. This way, as you wanted, if it is to be different, then the user could just delete it.

Regards,

Jeff
Death Slaught's Avatar
Site Addict
 
Join Date: Aug 2007
Location: Tennessee
Posts: 952
#3: Dec 5 '07

re: Input box match


As for the curser appearing after the last digit when the page is loaded.

Well i'm not entirely sure if you can do this or not. You can't in HTML, and CSS that's for sure, however, it may be possible in JavaScript so I would ask over there.

Hope it helps, Thanks, Death
Member
 
Join Date: Oct 2007
Posts: 70
#4: Dec 6 '07

re: Input box match


Hi Death Slaught,

Thanks for your suggestion,
One thing though, I didnt want the curser to be after the 1868 when the page loads. I want it to be after the 1868 when the text box recieves focus.
Any suggestions?
Death Slaught's Avatar
Site Addict
 
Join Date: Aug 2007
Location: Tennessee
Posts: 952
#5: Dec 6 '07

re: Input box match


Quote:

Originally Posted by phpmel

Hi Death Slaught,

Thanks for your suggestion,
One thing though, I didnt want the curser to be after the 1868 when the page loads. I want it to be after the 1868 when the text box recieves focus.
Any suggestions?

Same as before ask in the JavaScript forum.

Thanks, Death
Member
 
Join Date: Oct 2007
Posts: 70
#6: Dec 10 '07

re: Input box match


Hi all,

I wanted to find out something.
If you have an input box on an html form and you wanted it to operate as follows.
It will be used to enter a phone number with no dashes. The phone number can have 10,11,even 15 digits(different parts of the world).
I wanted the input box to have the digits 1868 in the beginning of the box and let the curser be after the last 8 digit when the box gets focus so that the user could enter the other numbers after 1868 for local calls.Otherwise, The user could press backspace and delete the 1868 digits for international calls and type the entire international call number.

Is this possible at all?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Dec 10 '07

re: Input box match


See this thread.

That would give you the cursor position. You can set the cursor position too.
Reply