jQuery Validate remote method usage to check if username already exists

I’ve managed to get this to work by changing the PHP technique I was using, here’s my PHP: <?php require_once “./source/includes/data.php”; header(‘Content-type: application/json’); $request = $_REQUEST[‘username’]; $query = mysql_query(“SELECT * FROM mmh_user_info WHERE username=”$username””); $result = mysql_num_rows($query); if ($result == 0){ $valid = ‘true’;} else{ $valid = ‘false’; } echo $valid; ?> Thanks everyone here … Read more

jQuery Validate Plugin – How to create a simple custom rule?

You can create a simple rule by doing something like this: jQuery.validator.addMethod(“greaterThanZero”, function(value, element) { return this.optional(element) || (parseFloat(value) > 0); }, “* Amount must be greater than zero”); And then applying this like so: $(‘validatorElement’).validate({ rules : { amount : { greaterThanZero : true } } }); Just change the contents of the ‘addMethod’ … Read more

jQuery Validate – Enable validation for hidden fields

The plugin’s author says you should use “square brackets without the quotes”, [] http://bassistance.de/2011/10/07/release-validation-plugin-1-9-0/ Release: Validation Plugin 1.9.0: “…Another change should make the setup of forms with hidden elements easier, these are now ignored by default (option “ignore” has “:hidden” now as default). In theory, this could break an existing setup. In the unlikely case … Read more