How to replace form field value or fill in form field using jQuery

This article was written by in February 15, 2015, & may not be posted on other sites!
Original source url for this article: How to replace form field value or fill in form field using jQuery

How to replace form field value or fill in form field using jQuery.
It is very easy to auto fill in text in form fields using jQuery or replace a form field value already there. This is How to replace form field values or fill in form field using jQuery.

How to replace form field value or fill in form field using jQuery

 

How to replace form field value or fill in form field using jQuery

Simply use this jQuery code:
$("input").val("My text");

Or if your text is saved inside a variable, use this jQuery code:
var myText = "My text";
$("input").val(myText);

To target a specific field, this code might be better:
$('input[name="number"]').val("0123");

Or target a text field by ID, use this jQuery code:
$('#my-field input').val("My text");

 

Spread the word

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *