Sarthak Sarthak - 23 days ago 4
HTML Question

HTML form text - save data as url using javascript

I am saving the form text(facebook page name) entered by the user into to database.

<form:input type="text" path="fName" value="${bean.fName}" title="Page Name"/>

What i want is when the user enters the fbpage name in the form text it should automatically change into fb-url. For example if user enters "google" the form text should change to "".
How can i achieve this by Javascript ?


Hello If I understand your problem that text should be change into url in the same textbox then try the below code

$("#user").change(function()  //user is textbox ID
$("#user").val(""+$("#user").val()); //added google you can use facebook also

check below fiddle Url Fiddle Link