<html> <head> <script> var p = /[^abc]/; function testMatch() { var str = document.getElementById("textfield").value; if (p.test(str)) { alert("The string \"" + str + "\" contains characters other than a, b, or c."); } else { alert("The string \"" + str + "\" does not contain characters other than a, b, or c."); } } </script> </head> <body> <h3> Checking the availability of a string </h3> Enter the String: <input type="text" id="textfield" /> <input type="button" value="Check" onclick="testMatch();" /> </body> </html>