How do I check if a text field has a certain text entered into it when a button is pushed?
Asked
Active
Viewed 38 times
-7
-
2Possible duplicate of [How do I get the value of text input field using JavaScript?](https://stackoverflow.com/questions/11563638/how-do-i-get-the-value-of-text-input-field-using-javascript) – connoraworden Apr 09 '18 at 15:31
1 Answers
0
This bit of code will search the string 'searchMe' for the string 'lookFor' and store the result (boolean) inside of 'result'
let searchMe = 'can you find me in here?'; //string to search
let lookFor = new RegExp("find me"); //reg exp pattern to look for
let result = lookFor.test(searchMe); //result of the search (true/false)
Try and apply this logic to your button click handler. Good luck!

LawfulGood
- 177
- 5