hello,
I am trying to validate empty textbox value by javascript in Firefox. It is working fine in IE but not in Firefox.
Note - code is for ASP.NET
<script runat="server">
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
Button1.Attribu tes.Add("onclic k", "javascript:che ckForm();");
}
</script>
<script type="text/javascript">
function checkForm()
{
if(document.get ElementById('tx tUserName').val ue =="")
{
if (window.event) //IE
{
alert("IE");
window.event.re turnValue = false;
}
}
else //Firefox
{
alert("Firefox" );
event.preventDe fault(); // <-- What should I write here instead
//retrun false; is also not working
}
}
Please help. Thanks
I am trying to validate empty textbox value by javascript in Firefox. It is working fine in IE but not in Firefox.
Note - code is for ASP.NET
<script runat="server">
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
Button1.Attribu tes.Add("onclic k", "javascript:che ckForm();");
}
</script>
<script type="text/javascript">
function checkForm()
{
if(document.get ElementById('tx tUserName').val ue =="")
{
if (window.event) //IE
{
alert("IE");
window.event.re turnValue = false;
}
}
else //Firefox
{
alert("Firefox" );
event.preventDe fault(); // <-- What should I write here instead
//retrun false; is also not working
}
}
Please help. Thanks
Comment