Link to link on phone numbers
I have a form where various user information is registered, including phone numbers and, once registered, you can view the registration by opening a form equal to the previous one with disable fields equal to the fields filled in at the time of registration
I would like to turn this number into a link for the user to be able to call pro form number if it is on a mobile device and I thought it would be just me to put a href
, but as I am taking this information from the bank and throwing it into a text box, I don't know how to turn it into a link.
<div class="form-group col-md-6">
<label for="telefone">Telefone:*</label>
<div class="input-group phone">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span><input required type="phone" class="form-control" id="telefone" name="telefone" placeholder="Digite o seu telefone:" value="<?=$row['telefone'];?>" disabled>
</div>
</div>
I tried the same href and it was like this:
Can anyone give me an idea of how to do this?
3 answers
Since you want Click to work on a input
, and not on a anchor
, I suggest creating a click event on your input, via javascript.
Add the onclick property to the input:
onclick="window.open('tel:<?=$row['telefone'];?>');";
Would look like this:
<div class="form-group col-md-6">
<label for="telefone">Telefone:*</label>
<div class="input-group phone">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span><input required type="phone" class="form-control" id="telefone" name="telefone" placeholder="Digite o seu telefone:" value="<?=$row['telefone'];?>" disabled onclick="window.open('tel:<?=$row['telefone'];?>');">
</div>
</div>
Just print the value in the href of tag A.
For example:
<a href="tel:<?=$row['telefone'];?>"><?=$row['telefone'];?></a>
You may need to remove special characters from href if it doesn't work in a specific browser. For this you can use:
<a href="tel:<?=preg_replace('/[^0-9]/', '', $row['telefone']);?>"><?=$row['telefone'];?></a>
I hope I helped.
You can try:
<a href="tel:55-5555-12345">(55) 5555-12345</a>