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!

calling a function

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
Hi

I have a ASP page called 'business' which has text fields etc and on the click of a button 'Submit form' it has this

Code:
<INPUT TYPE=&quot;submit&quot; NAME=&quot;butEdit&quot; VALUE=&quot;Submit Form&quot; ONCLICK=&quot;return validate();&quot; style=&quot;font-family: Arial Black; border: 3 solid #000080; padding-top: 0; padding-bottom: 2&quot;>  

at the end of the form there are various functions written in Javascript such as

Code:
<!--when the user clicks the register now button it calls the method Validate --> 
<!--under are the functions called within the function 'Validate' --> 


<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Hide script from older browsers
//************************************************************************************************************
//    function to validate a number that is typed
function isDigit(c)
    {
    var test = &quot;&quot; + c;
    if (test == &quot;0&quot; || test == &quot;1&quot; || test == &quot;2&quot; || test == &quot;3&quot; || test == &quot;4&quot; 
    || test == &quot;5&quot; || test == &quot;6&quot; || test == &quot;7&quot; || test == &quot;8&quot; || test == &quot;9&quot;)
        {
        return true;
        }
    return false;
    }
//************************************************************************************************************
//		function to validate a row of numbers by calling the isDigit function numbers (K++)

However when the button is clicked no validation is performed. Any ideas?

Ta
Richey
 
You could try something like this...

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
// Set the background colour
function checkIt()
{
if( document.myForm.txtData.value == &quot;&quot;)
{
alert(&quot;Text box cannot be blank.&quot;);
return false;
}
return true;
}

function numberChecker(event)
{
if (navigator.appName == &quot;Microsoft Internet Explorer&quot;)
{
if (event.keyCode < 48 || event.keyCode > 57)
{
alert(&quot;I want only numbers.&quot; );
return false;
}
else
return true
}
else
{
if (event.which < 48 || event.which > 57)
{
alert(&quot;I want only numbers.&quot; );
return false;
}
else
return true
}

}

</SCRIPT>

</HEAD>
<BODY>
<FORM NAME=&quot;myForm&quot; METHOD=&quot;POST&quot; ACTION=&quot;handler.asp&quot; onsubmit=&quot;return checkIt()&quot;>
<CENTER>
<INPUT NAME=&quot;txtData&quot; onKeyPress=&quot;return numberChecker( event )&quot;><BR>
<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;>
</CENTER>
</FORM>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top