Forum Moderators: open
if (theForm.filename.value == "#")
{
alert("Please take the # sign out of the filename field.");
theForm.filename.focus();
return (false);
}
return (true);
}
//--></script>
In the form:
<input TYPE="FILE" NAME="filename" size="20">
Basically, what the above does is check for there ONLY being a # in the field. How can I check to make sure what is entered does not CONTAIN a "#"?
Thanks,
Jim
You could try using indexOf instead, like this:
<script type="text/javascript">
function Validate()
{
var hash = theForm.filename.value.indexOf("#");
if (hash != -1)
{
alert("Please take the # sign out of the filename field.");
theForm.filename.focus();
return (false);
}
return (true);
}
</script>
<form name="theForm">
<input type="text" name="filename" />
<input type="button" value="click" onclick="Validate()" />
</form>
Then the # can be anywhere!
Good luck :)
if (theForm.filename.value.match(/#/))
Jim