I have made a simple webpage to check for regular expressions.
<html>
<head>
<script type="text/javascript">
var illegalChars = /^[&*%]+$/
function validate_form(thisform)
{
with (thisform)
{
if (illegalChars.test(regextest.value)==true)
alert('Illegal Characters');
{regextest.focus();return false;}
}
}
</script>
</head>
<body>
<h2>RegEx Stuff</h2>
<form action="regex.html" onsubmit="return validate_form(this)" method="post">
Enter characters:
<br/>
<input type="text" name="regextest" size="60">
<br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
The idea being I want to scan the input string and return false if any of the illegal chars are found - in this case &, * and %.
The illegalChars variable will contain all charcaters I want to avoid being put into a DB.
It works if I put 1 character in the text field otherwise it fails. I want to check for illegal charcaters throughout the string. So something like "Chalk&Cheese" should fail. Also multiples of the illegal characters.
Any suggestions. Cheers.