Cleavis
asked on
Check Form Input For Invalid Characters
I can't get this to work. what went wrong?
<SCRIPT>
function checkSearch(input)
{
var value = true;
var notValidChars = /[^a-z0-9]/i;
if( notValidChars.test(input.v alue) )
{
alert("Please do not use invalid symbols!");
input.focus();
value = false;
}
return value;
}
</SCRIPT>
<body>
<form method="post" action="/cgi-bin/check.cgi " onsubmit="return checkSearch(this.Search)">
<p> </p>
<p><input type="text" name="T1" size="20"></p>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>
<SCRIPT>
function checkSearch(input)
{
var value = true;
var notValidChars = /[^a-z0-9]/i;
if( notValidChars.test(input.v
{
alert("Please do not use invalid symbols!");
input.focus();
value = false;
}
return value;
}
</SCRIPT>
<body>
<form method="post" action="/cgi-bin/check.cgi
<p> </p>
<p><input type="text" name="T1" size="20"></p>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>
ASKER
that works for T1.
is there a way to check all input fields in the form?
is there a way to check all input fields in the form?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You.
Thanks for the points, GfW
<SCRIPT>
function checkSearch(input)
{
var value = true;
var notValidChars = /[^a-z0-9]/i;
if( notValidChars.test(input.v
{
alert("Please do not use invalid symbols!");
input.focus();
value = false;
}
return value;
}
</SCRIPT>
<body>
<form method="post" action="/cgi-bin/check.cgi
<p> </p>
<p><input type="text" name="T1" size="20"></p>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>