How to get input value in JavaScript ? | How do I get the value of text input field using JavaScript?

How to get input value in JavaScript ? | How do I get the value of text input field using JavaScript?

जावास्क्रिप्ट में इनपुट वैल्यू कैसे प्राप्त करें? | मैं जावास्क्रिप्ट का उपयोग करके टेक्स्ट इनपुट फ़ील्ड का मूल्य कैसे प्राप्त करूं?

In javascript it is very easy to get input value. First you need to understand the concept what is input feild in javascript.

जावास्क्रिप्ट में इनपुट वैल्यू प्राप्त करना बहुत आसान है। सबसे पहले आपको इस अवधारणा को समझने की जरूरत है कि जावास्क्रिप्ट में इनपुट फील्ड क्या है।
what is input feild in javascript?
In JavaScript input text property is used  to set or return the value of a text input field and value property contains either the default value that is present upon loading the element, the value entered by the user, or the value assigned by the script.
जावास्क्रिप्ट में इनपुट फील्ड क्या है?
जावास्क्रिप्ट इनपुट में टेक्स्ट प्रॉपर्टी का उपयोग टेक्स्ट इनपुट फ़ील्ड के मान को सेट या वापस करने के लिए किया जाता है और वैल्यू प्रॉपर्टी में या तो डिफ़ॉल्ट मान होता है जो तत्व लोड करने पर मौजूद होता है, उपयोगकर्ता द्वारा दर्ज किया गया मान, या स्क्रिप्ट द्वारा असाइन किया गया मान।

Code To Get Input Value In JavaScript:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Get the value of input feild using javascript</title>
</head>
<body>
    <input type="text" id="text-enter" >&nbsp<button type="button" onclick="showoutput()">Add Me!</button>
    <p id="show-text"></p>
<script>
function showoutput() {
 var var1=document.getElementById("text-enter").value;//Get Input Field Value
  console.log(var1);//Display Output In Console
  alert(var1);//Display Output In Alert Box
}
</script>
</body>
</html>

Output:

get-input-value-in-javascript


Previous
Next Post »

Please do not entering spam link in the comment box ConversionConversion EmoticonEmoticon