D
davidjcampos
I'm a definite newbie to javascript, but I have put together some
workable code from several different examples on the web. I am using
both "onchange" event handlers as well as an "onsubmit" event
handler. The "onchange" event handlers are working great. When a
user enters an amount that is greater then the amount of vacation time
they actually have, a message pops up letting them know that they must
enter a smaller amount. Along with this, I would like to use a simple
"onsubmit" event handler that basicially checks the same thing that
the "onchange" event handler does, but prevents the form from being
submitted if the amount entered is incorrect. Here is my "onsubmit"
event handler that is not working. Even if an invalid amount is
entered it still submits the form.
<script type="text/javascript" language="JavaScript">
function validateSubmitInput()
{
userInput = new String();
userInput = this.form1.txtCompTime.value;
var JSCompTimeBalance = "<%= CompTimeBalance %>"
var JSCompTimeTextBox = document.form1.txtCompTime.value
if (parseFloat(JSCompTimeTextBox) > parseFloat(JSCompTimeBalance))
{
alert("There is a problem");
return false;
}
return true;
}
</script>
<form name="form1" method="post" action="Timesheet3_Sent.asp"
ONSUBMIT="validateSubmitInput();">
<input name="txtCompTime" type="text" class="TextboxSmaller"
id="txtCompTime" value="0" onChange= "validateInput(this.value)();">
</form>
Any help would be appreciated.
workable code from several different examples on the web. I am using
both "onchange" event handlers as well as an "onsubmit" event
handler. The "onchange" event handlers are working great. When a
user enters an amount that is greater then the amount of vacation time
they actually have, a message pops up letting them know that they must
enter a smaller amount. Along with this, I would like to use a simple
"onsubmit" event handler that basicially checks the same thing that
the "onchange" event handler does, but prevents the form from being
submitted if the amount entered is incorrect. Here is my "onsubmit"
event handler that is not working. Even if an invalid amount is
entered it still submits the form.
<script type="text/javascript" language="JavaScript">
function validateSubmitInput()
{
userInput = new String();
userInput = this.form1.txtCompTime.value;
var JSCompTimeBalance = "<%= CompTimeBalance %>"
var JSCompTimeTextBox = document.form1.txtCompTime.value
if (parseFloat(JSCompTimeTextBox) > parseFloat(JSCompTimeBalance))
{
alert("There is a problem");
return false;
}
return true;
}
</script>
<form name="form1" method="post" action="Timesheet3_Sent.asp"
ONSUBMIT="validateSubmitInput();">
<input name="txtCompTime" type="text" class="TextboxSmaller"
id="txtCompTime" value="0" onChange= "validateInput(this.value)();">
</form>
Any help would be appreciated.