Archive for : July, 2013

Create a new rule for jquery.validator plugin

Create a new simple rule for jquery.validator plugin 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");

Apply the new rule:


$('validatorElement').validate({
rules : {
amount : { greaterThanZero : true }
}
});

Javascript strip tags

A very useful snippet code to strip html tags using Javascript:


var strippedString = string.replace(/(<([^>]+)>)/ig,"");

Read entire article and commentshere