Grzegorz Węgorzewski Grzegorz Węgorzewski - 1 year ago 172
jQuery Question

How to validate php md5 string with jquery validate

I have string (md5 php) and i want to valid that with jquery validation with md5 jquery plugin

Html code

<input type="password" name="token" id="token">
<input type="hidden" name="hiddenToken" id="hiddenToken">

Jquery code

var rules = rules:{
token: {
required : true,
equalTo: "#hiddenToken"

and also

$("#token").on("keyup", function(){
var md5 = $.md5($(this).val());

When im console log those string are identical.
Any one knows why jquery validate give me an error token invalid

Answer Source

I think that the actual value of the token field (not hashed) is compared to the hash of the hiddenToken field. And so it is clear that you get an error because they are surely not the same.

You could try to change the code after on keyup to:

$("#token").on("keyup", function(){

Probably it will work but I could not have tested it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download