How to put validation with Javascript in Firefox.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitinp
    New Member
    • Aug 2006
    • 8

    How to put validation with Javascript in Firefox.

    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
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Here is an alternate global event:
    A global event...in Firefox?

    Here is a related thread:
    Mouse position in FireFox / NS

    Comment

    Working...