I want a logic for html page. I made a form,and if user enters any numeric value in text field a dialog box should apear | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I want a logic for html page. I made a form,and if user enters any numeric value in text field a dialog box should apear

31st Mar 2017, 2:44 PM
sumer
sumer - avatar
3 Answers
+ 5
You can have an onChange event listener on input Whenever input field data changes your event listener will be called. Inside that you can check for ASCII values of keypressed..If ASCII lies between what you want open dialog box else not.
31st Mar 2017, 3:13 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 2
<input onkeypress="checkInput()"> <script> function checkInput(){ if(event.keyCode>=48 && event.keyCode<=57){ prompt("Enter Something"); } } </script>
31st Mar 2017, 4:33 PM
Ashwani Kumar
Ashwani Kumar - avatar
0
can u post code for that.. i will be thankful
31st Mar 2017, 4:21 PM
sumer
sumer - avatar