Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Form doesn't stop, just submits right after validateddfield. @Firefox only

    hi dears,

    I'm trying to do simple form validation.
    But the form submits right after validated! at FireFox only. as i tried it at IE it works fine.

    condition:
    if return false the event must be stop, killed submitting the form value's.

    my form is:
    Code:
    <form action="index.php" id="cat_form" method="post" name="cat_form" onsubmit="return cats();">
    my js is:

    Code:
    function cats()
    {
            if  (document.cat_form.txttitle.value=="")
            {
            alert ("Sorry, Don't keep it blank!!")
            cat_form.txttitle.focus();
            return false;
            }
    	else if (document.farticle.txtperpg.value==0)
    	{
    		alert("Sorry, Value must be grater than Zero"); 
    	        cat_form.txtperpg.focus();
    		return false; 
    	}
    	else
    	{
    		 return true;	
    	}
    }
    Any Idea ?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,864
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    if (document.cat_form.txttitle.value=="")
    {
    alert ("Sorry, Don't keep it blank!!")
    cat_form.txttitle.focus();
    return false;
    }
    Don't you need that document reference, when you refer an element for the second time?
    Last edited by abduraooft; 07-22-2010 at 06:44 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks abduraooft for the great fast response.

    its worked.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •