问题
I can't call my javasript using a freetextbox in asp.net.
here's code my in javascript:
function validateFreetextbox()
{
if(document.FTB_API["txt_Decs"].GetHtml == '' )
{
alert("Please Fill up desciption.");
return false;
}
else
{
return true;
}
}
my code's in asp.net for button:
<asp:Button ID="btn_Add" runat="server" OnClick="btn_Add_Click" Text="Add"
Width="231px" Font-Size="11px" Font-Bold="false" ForeColor="#333333"
onclientclick=" validateFreetextbox()" />
回答1:
should be onclientclick="validateFreetextbox();"
Edit: for your help, I have just created page at my end try and its working... can you make new page and check this at your end...
<html xmlns="http://www.w3.org/1999/xhtml">
<script language="javascript" type="text/javascript">
function validateFreetextbox()
{
alert('Called');
// if(document.FTB_API["txt_Decs"].GetHtml == '' )
// {
// alert("Please Fill up desciption.");
// return false;
// }
// else
// {
// return true;
// }
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btn_Add" runat="server" Text="Add" Width="231px"
Font-Size="11px" Font-Bold="false" ForeColor="#333333" OnClientClick="validateFreetextbox()" OnClick="btn_Add_Click" />
</div>
</form>
</body>
</html>
来源:https://stackoverflow.com/questions/5495662/javascript-function