Skip to content

Instantly share code, notes, and snippets.

@kikitux
Created April 26, 2016 06:08
Show Gist options
  • Save kikitux/c8e6a332e66f60ca4b423c1de449cf33 to your computer and use it in GitHub Desktop.
Save kikitux/c8e6a332e66f60ca4b423c1de449cf33 to your computer and use it in GitHub Desktop.
function checkField(element, parent)
{
if ($(element).attr("type") == "radio") {
if ($("input[name=" + $(element).attr("name") + "]:checked").length > 0) {
if (!$(element).parent().hasClass("filled")) {
if ($(parent).data("required").filled < ($(parent).data("required").total)) {
$(parent).data("required").filled++;
$(element).parent().addClass("filled");
}
}
console.log($(parent).data("required").filled);
$(element).parent().removeClass("failed-radio");
}
}
else
{
if ($(element).val().length == 0) {
console.log('this thing is so fucking broken :*!');
if ($(element).hasClass("filled")) {
$(parent).data("required").filled--;
$(element).removeClass("filled");
}
console.log('atleast it added the class :(');
$(element).addClass("failed");
console.log($(parent).data("required").filled);
}
else {
if (!$(element).hasClass("filled")) {
if (($(parent).data("required").filled < $(parent).data("required").total)) {
$(parent).data("required").filled++;
$(element).addClass("filled");
console.log('YAYAYAYYA');
}
}
console.log($(parent).data("required").filled);
$(element).removeClass("failed");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment