+ 2
How do you check the contents of an input (HTML)
How do you check the contents of an input and run a script?
3 Answers
0
document.querySelectorAll(input)[0].value;
+ 1
Well, the first option would just to set a variable to prompt the user for input in JS. However, if you want to set an input field in HTML and set that as your variable, you add the input field within a form, and set an onsubmit event attribute to the input which indicates the JavaScript to go to a certain function once the form is submitted.
For example:
<form>
<input onsubmit = "func" type = "text">
<input type = "submit">
</form>
0
But how do you check the text for something. For instance check if the box has 'example' in it.