Question

I am having trouble with manual form submission with javascript in Firefox and IE. There are no problems in Chrome and Opera.

As the user submits form, I intercept it with javascript/jquery, hash the password and resubmit the form.

I have tried many alternate variations using only javascript which also dont work.

Also the problem is this specific code because without it, it works perfectly.

 window.onload = main;


function main()
{                                           // Problem with Firefox and IE
                                            // Form seems to not submit correctly after the manual submit
 $('#loginForm').submit(function(event) 
    {
        if (typeof event.originalEvent !== 'undefined') 
        {
            event.preventDefault();
        }
        else
        {
            return;
        }


        var passHash = CryptoJS.SHA256($('#password').val());
        $('#password').val(passHash.toString());

     //   document.getElementById('loginForm').submit();
        $('#loginForm').trigger('submit');
    });  
}
Was it helpful?

Solution

Too complex, it only needs:

function main()
{                                           

    $('#loginForm').submit(function(event) 
    {

        var passHash = CryptoJS.SHA256($('#password').val());
        $('#password').val(passHash.toString());

        return true;
    });  
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top