1

I have input text like below

<input type="text" value="google.com" name="link">

user can change input and submit the form. In the same input I want to show href to already set value. For example if value of input text is set to google.com then user can go to google.com on clicking url value in input box. at same input box user should be able to change value of input by clicking inside input box

I tried as

<input type="text" value="<a href='www.google.com'>google.com</a>" name="link">

but it is not allowed like that. It treats all text as value

If I use

<a href="www.google.com"><input type="text" value="google.com" name="link"></a>

then user can not edit field as when he clicks anywhere in input box it goes to link google.com. Is there any other way to achieve this so only text inside input will be clickable

hrishi
  • 1,610
  • 6
  • 26
  • 43
  • 1
    Possible duplicate of [Is it possible to place a link inside field?](https://stackoverflow.com/questions/21077208/is-it-possible-to-place-a-link-inside-input-field) – Aldi Unanto Jul 25 '17 at 07:00
  • 1
    you can make redirection on double click – Vineesh Jul 25 '17 at 07:08
  • @Aldi Unanto In my question I want to give edit option to user. Just not link in textbox – hrishi Jul 25 '17 at 07:11
  • @Vineesh Nice option but user should understand single click for edit and double click for redirect – hrishi Jul 25 '17 at 07:14
  • I don't think, same action(single click) we can perform different actions. – Vineesh Jul 25 '17 at 07:16
  • I need to notify user if he want to go to link then double click here – hrishi Jul 25 '17 at 07:17
  • Just a suggestion - you can put a label just below the textbox which have the hyperlink of the content that you type in the text box – Rahul Dasgupta Jul 25 '17 at 07:26
  • Put a new textbox below your original textbox in read only mode and with the help of javascript add link of that input value in run time - I didn't done this before not sure if it will work. – Prasad_Joshi Jul 25 '17 at 07:36

1 Answers1

0

This is unfortunately not possible in the way you've asked it in HTML 4 or below. Even with HTML5 which has several new INPUT TYPEs, including URL, it only does validation and has some other useful functions, but won't give you want you want.

You might look for some jQuery plugins that can help you do this, most use the same principals behind Rich Text or other online/web-based HTML WYSIWYG editors. I've had trouble locating them myself.

Coppied

for more information click here

Community
  • 1
  • 1
M Amir Shahzad
  • 190
  • 2
  • 16