how to get form field value in JQuery

JQuery Form Value Example

Simple JQuery example to get the HTML form field value using JQuery. HTML contains various element like text field, text area, radio button, check boxes etc. You can easily get the value of form field using JQuery.

jquery example
 

This tutorial explain you how to get the text field and text area value using JQuery.

To get value of HTMLinput field.


$("input").val();

 

To get value of HTML Text area field.


$("textarea").val();

 

JQuery example

<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

<script>

$(document).ready(function(){

$("button").click(function(){

alert("Text field value- " + $("#test").val());

alert("Text area value- " + $("#test1").val());

});

});

</script>

</head>

<body>



Name: <input type="text" id="test" value="umar farooque">


<textarea id="test1">

ptutorial

</textarea>

<button>Get form field values</button>

</body>

</html>

To learn more about JQuery example and see a lot of live example visit: JQuery Example

Do not forgot to like share and comment

 



The following two tabs change content below.
Umar Farooque Khan is Software developer/ web developer and professional blogger serving Worldwide on freelancer and ODesk platform to show the capability of his skills He is the founder of pTutorial.com. The main purpose of this site is sharing and exchanging of I.T. Knowledge.

Latest posts by Umar Farooque Khan (see all)