Skip to content Skip to sidebar Skip to footer

Jquery: How To Submit A Form With Edited User Inputed Values?

So for example I have a simple HTML form:

Login

Solution 1:

First -- I want to point out that I don't think this is a good idea. It's generally a bad idea to implement password hashing on the client side. Instead, the pass should be sent in plain text (over HTTPS) to the server, where it is then hashed using your preferred algorithm before storage. This has the added benefit of not advertising to potential attackers which hashing method is used, since that code exists only on the server.

That said: you're going to want to calculate that SHA value prior to form submit.

You could bind an event handler to the password field's blur event to update a hidden field's value with the new hash. Or you could add the update logic to the validation code.

Regardless of where the extra code goes, it will be much easier for you to prepare the hash prior to the form submit than it will be to send a second submission chasing after the first.

E.g.

<!-- add this to the form -->
<inputtype="hidden"name="sha_pass"value="" />// add this to the document ready handler
$('[name=pass]').blur(function() {
    $('[name=sha_pass]').val($.sha256($(this).val());
});

Post a Comment for "Jquery: How To Submit A Form With Edited User Inputed Values?"