Jump to content

Recommended Posts

I have written a fucntion in javascript for validation.

The submit button is inside a form

<input type="submit" name="submit_request" value="Submit" id="submit_req" onclick="return checkQ(event);" style="backgroundColor:Transparent;border:0;color:blue;width:100;"/>

This is the function

function checkQ()
{   
    //Validation
    var checkEmpty; //check empty text field
    var checkNum;   //check whether authorized value is greater than the requested value
    var checkStr    //check whether string is entered
    var qLength = document.getElementsByName("pQuantity[]").length;
    for(i=0;i<qLength;i++)
    {
        var pValue = document.getElementsByName("pQuantity[]")[i].value; //authorized quantity
        var reQnty = document.getElementsByName("quantity[]")[i].value; //requested quantity
        if(pValue != "")
        {
            checkEmpty = true;
        }
        else
        {
            alert("Quantity missing");
            checkEmpty = false;
            return false;
        }
        if(Number(pValue)>Number(reQnty))
        {
            alert("greater value");
            checkNum = false;
            return false;
        }
        else
        {
            checkNum = true;
        }
        if(!Number(pValue))
        {
            alert("You are only allowed to enter a number");
            checkStr = false;
            return false;
        }
        else
        {
            checkStr = true;
        }
    }
    if(checkEmpty==true && checkNum==true && checkStr==true)
    {
        alert("working");
        return true;
    }
}

It works fine in chrome and IE but for some reason even when every condition is satifisfied the form is not submitted in firefox. I get the alert dialogue box saying "working" but nothing happens after that. how to fix it

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.