HOW TO GET USER INPUT VALUE USING JAVASCRIPT

 USER INPUT VALUE





<!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>Document</title>
</head>
<body>
    <input type="text" name="" id="input">
    <button onclick="my()">click</button>

    <script>
        function my(){
            var x = 
        document.getElementById("input").value

            alert(x)
        }
    </script>
</body>
</html>

code like this so that you can access the value entered in input field and you can use it any where in the document

remember to use ( . )dot  

coding like this you can get anything which was entered by the user


there are some fixed properties for input field

accept
sets the value of accept attribute
autofocus
sets or returns whether input field must automatically focused when page load
default value
sets the default value of input field
disabled
sets or returns whether the file upload button is disabled or not
files
returns a file list object that represents the file or files selected with the file upload button
form
returns a reference to the form that contains the file upload button
multiple
sets or return whether a user is allowed to select more than one file in the file upload button
name
sets the value of the name attribute of input field
required
alerts user if the input field is not filled
type
returns which type of form element is the input field
value
returns the path or name of the selected file
alt
specifies alternate text
autocomplete
sopecifies whether an input element has autocomplete enabled
checked
specifies whether an input element is preselected or not
form
specifies the form the input element belongs to
formaction
specifies the url of the file that will process the input control when the form is submitted
height
specifies height of an input field
list
refers to a datalist element that contains predefined options for an input element
checked
specifes that an input field should be preselected when the page loads only for checkbox and radio
disabled
it says that input field should be disabled
max
specifies the maximum value for an input field
maxlength
specifies the maximum number of character for an input field
min
specifies the minimum value for an input field
pattern
specifies the regular expression to check the input value
readonly
specifies that an input field is read only and cannot be changed
required
specifies that an input field is required
size
specifies the width of an input field
step
specifies the legal number intervals for an input field
value
specifies the dafault value for an input field

thanks for visiting .......


please subscribe my youtube channel 

@kssvinay

Comments

Popular posts from this blog