I want to add a fixed country(UK) code and its not changeable in input box like below image:
And the value +44
is fixed with the other 11 digits. How to add this in input elements.
N.B: +44 also added with other values after submitting the form.
I want to add a fixed country(UK) code and its not changeable in input box like below image:
And the value +44
is fixed with the other 11 digits. How to add this in input elements.
N.B: +44 also added with other values after submitting the form.
You'll need to add another element that'll work as a prefix for this input.
#input-wrapper * {
position: absolute;
}
#input-wrapper label {
z-index: 99;
line-height: 25px;
padding: 2px;
margin-left: 5px;
}
#input-wrapper input {
height: 25px;
text-indent: 35px;
}
<div id="input-wrapper">
<label for="number">+44</label>
<input id='number' onchange="this.value = '+44' + this.value" type="text">
</div>
If you want the +44
to be added without showing up in HTML, you can add an event in JS file.
document.getElementById("number").addEventListener('change', function(e){
e.target.value = '+44' + e.target.value;
});
You can position the text on top of the input field to make it look as if it is inside it. Something like this:
<input type="text" name="phone" style="width:3.5em;padding-left:1.5em;font:inherit"><span style="margin-left:-3em;margin-right:10em;">+44</span>