+ 2

How do you check the contents of an input (HTML)

How do you check the contents of an input and run a script?

24th Jan 2018, 3:31 AM
YoBoi
3 Respuestas
0
document.querySelectorAll(input)[0].value;
20th Jun 2019, 3:48 PM
YoBoi
+ 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>
24th Jan 2018, 3:49 AM
Faisal
Faisal - avatar
0
But how do you check the text for something. For instance check if the box has 'example' in it.
24th Jan 2018, 12:18 PM
YoBoi