Skip to content

Instantly share code, notes, and snippets.

@wsmoak
Created May 4, 2015 17:47
Show Gist options
  • Save wsmoak/aa285f7210bf5278ac86 to your computer and use it in GitHub Desktop.
Save wsmoak/aa285f7210bf5278ac86 to your computer and use it in GitHub Desktop.
Chargify - Default component quantity to 1 and require quantity to be > 0
$(function () {
var component1 = $("#component_allocated_quantity_XXXXX");
component1.val(1);
$("#subscription_submit").click(function(){
if ( component1.val() <= 0 ) {
component1.addClass("field-error");
return false;
}
});
component1.blur(function(){
if ($(this).val() > 0 ) {
$(this).removeClass("field-error");
} else {
$(this).addClass("field-error");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment