So this should be a relativly easy thing for most people but I'm having trouble with it. I'm using the jquery validate plugin and would like to return a random vaule on success. Right now I'm trying to use.
var success_message = new Array (); success_message[0] = "Good!";
success_message[1] = "Ok!";
success_message[2] = "Great!";
success_message[3] = "Perfect!";
success_message[4] = "Nice!";
success_message[5] = "Awesome";
var i= Math.floor(5*Math.random())
then where I need to output the value use
$(document).ready(function(){
var validator = $(".contactform").validate({ ...
success: function(label) {
label.addClass("valid").text(success_message[i])
}
}); //end form validate code
});
This selects a random value but uses the same vaule for each success message instead of selecting a different one for each field
I'm sure There is an eaiser way to do this so feel free to scrap my code. I also don't think i Sorry I'm new to this i just thought it would be a fun idea to return a random sucess message.
Edit: Cleaned up code and got it partly working. Thanks