Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On BLUR not firing

Recently changing from writing small vb apps to web apps. Haven't switched over to C# at this time.

Trying to get an ASP.net Form to add a couple text boxes and show the results in another text box.

This is on and ASP.NET 4.0 form using the FormView Control in insert mode. The issue is that no matter if I click in the box, Tab into the box or out it doesn't ever seem to fire the JavaScript

<script language="javascript" type="text/javascript">
function SumCalc() 
{
    Window.alert("On Blur");
    var num1 = parseInt(document.getElementById("LeaveHoursTextBox").value);
    var num2 = parseInt(document.getElementById("LeaveHours2TextBox").value);
    var num3 = parseInt(document.getElementById("LeaveHours3TextBox").value);
    var TotalTime = num1 + num2 + num3

    document.getElementById("HoursTextBox").value = TotalTime;
}
</script>

Below is part of my html. Long page so I didn't post the whole of it..

<asp:TextBox ID="LeaveHoursTextBox" runat="server" 
Text='<%# Bind("LeaveHours") %>' 
onblur = "return sumCalc()"/>
like image 498
dibblm Avatar asked Feb 19 '23 17:02

dibblm


1 Answers

Javascript is case sensitive. Change your call to return SumCalc(), also Window.alert won't work, use window.alert or just alert instead.

Further remove the spaces from onblur = "return sumCalc()", valid html would be onblur="return sumCalc()".

like image 114
Michal Klouda Avatar answered Feb 23 '23 10:02

Michal Klouda