I am trying to submit my form named 'vform' by using javascript and ajax.Here
Button named 'show' is being used to show the 'div' containing form named vform and that form calls codevalidate function and there it submits the form using some ajax code..Where i am getting error is vform.submit().Here's the html and js code(I know error is in if condition but do not know where)

**html:**

```
<button id="show" onClick="javascript:codefield(); return false";>Apply for Discount</button>
            <div id="apply" style="display:none">Voucher code<br>
            <form id="vform" name="vform" action="" method="post" onsubmit="javascript:codevalidate(); return false;" >
            <input type="text" name="code" id="code"><br>
            <span id="error" style="color:red"></span><br>
            <input type="submit" name="btn" value="apply" id="btn" ></form>
            </div>

```

**javascript:**

```
function codevalidate()
{

if(document.getElementById('code').value!=="")
{
$.post("couponajax.php",{code:$("#code").val()},
    function(data)
    {   
        if(data=='1')
        {
            //alert("success");
            vform.submit();
            return true;
        }
        else 
        {
            document.getElementById('error').innerHTML="You have entered a wrong code!";
            return false;
        }

    });

}
else
{
document.getElementById('error').innerHTML="Code can't be empty!";
return false;
}

return false;

```

}

codefield function is just displaying the div on onclick event and ajax call is just checking whether the code exists in database or not..if exists returns 1 else 0.
The problem is alert message is being displayed but form is not being submitted. How can I fix this problem?