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(object sender, EventArgs e)
{
if (!IsPostBack)
Button1.Attributes.Add("onclick", "javascript:checkForm();");
}
</script>
<script type="text/javascript">
function checkForm()
{
if(document.getElementById('txtUserName').value =="")
{
if (window.event) //IE
{
alert("IE");
window.event.returnValue = false;
}
}
else //Firefox
{
alert("Firefox");
event.preventDefault(); // <-- What should I write here instead
//retrun false; is also not working
}
}
Please help. Thanks