How to call a JS function on the form loading?

aspfun

Active member
Joined
Feb 16, 2010
Messages
34
Programming Experience
5-10
How to call the function validate() on the form loading?
There is a form in which another program will fill some text boxes
automatically.
I need this JS function to test the value of text boxes and give user a alert
if any text box is empty.

<script type="text/javascript">
function validate()
{
var t1 = document.getElementById('<%=txtOrderProduct.ClientID%>');
var t2 = document.getElementById('<%=txtOrderBy.ClientID%>');

if(t1.value == "" && t2.value == "")
{
alert("Empty');
}
}
</script>
 
Someone show me:
<body onload="validate();">
It works in a simple page. But, how to do it in a content page? There is no <body> tag
 
what about your masterpage?
 
Back
Top