permaculture playing cards*
The moose likes HTML, CSS and JavaScript and the fly likes Changing A Form Field Value On Submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Changing A Form Field Value On Submit" Watch "Changing A Form Field Value On Submit" New topic
Author

Changing A Form Field Value On Submit

Jason Ferguson
Ranch Hand

Joined: Aug 09, 2007
Posts: 58
I am attempting to make my application login slightly more secure by hashing a password via javascript to sha-256 BEFORE sending it to the server.

So, the user puts their password into a password field:

<input type="password" name="userPassword" id="userPassword" />

On submit, I need to run the sha_256 function on userPassword, then submit. So, I need a javascript function to fire off on the form's onSumit action.

This is probably simple, but I'm not sure. Can someone help?

Jason
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
Something like this should do the trick:


Ping & DNS - my free Android networking tools app
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
yep,

what you can do is just have the type of input just be a button instead of a submit, then you can just assign your hashfunction to the onclick method of that button input.

then after you hash and all that stuff in your function, just use the .submit() function like so.



it's either .submit or .submit() can't remember off hand.

Justin Fox


You down with OOP? Yeah you know me!
Jason Ferguson
Ranch Hand

Joined: Sep 16, 2007
Posts: 47
Thanks guys. I hadn't done anything like this in awhile, and had totally forgotten how to do it.

Unfortunately, it doesn't solve the debate whether hashing on the client side and passing the hash makes the app any more secure.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
I'd probably use SSL to make a secure connection instead of using hashs. If the password seems worth securing, then so should the actual data.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing A Form Field Value On Submit
 
Similar Threads
using ajax to populate select box
inputHidden causing conversion problems
Validator Framework and Javascript
Javascript submit problem
using the hidden value fields