Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return false not working

Status
Not open for further replies.

GuyPhempoompanitch

Programmer
Jul 11, 2006
6
US
Please help me. I can't seem to find what is not correct here. Basically I'm trying to stop the form from being submitted if the alert box is shown. Thanks.

FORM:
<form name="search" method="post" action="search/dsp_searchResults.cfm" onsubmit="checkWR(document.getElementById('RequestId').value);" target="Main">
Quick Search: <input type="text" name="RequestID" id="RequestId" value="WR Number" onFocus="this.value='';" class="searchInput"><br>
</form>

JS:
<script language="JavaScript">
function checkWR(sText)
{
var ValidChars = "0123456789,";
var Char;

for (i = 0; i < sText.length; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
alert("Please enter only numbers in the Number field";
return false;
}
}
}
</script>


 
Right here:

Code:
<form name="search" method="post" action="search/dsp_searchResults.cfm" onsubmit="[!]return [/!]checkWR(document.getElementById('RequestId').value);" target="Main">

Another thing, you alert is missing a ')'


[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top