Grzegorz Węgorzewski Grzegorz Węgorzewski - 3 months ago 36x
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


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.