<html> <head> <script> var p = /\d/; function testMatch() { var str = document.getElementById("textfield").value; if (p.test(str)) { alert("The string \"" + str + "\" contains digits."); } else { alert("The string \"" + str + "\" does not contain digits."); } } </script> </head> <body> <h3>Checking the availability of character in given range.</h3> Enter the String: <input type="text" id="textfield" /> <input type="button" value="Check" onclick="testMatch();" /> </body> </html>