Created
September 9, 2016 18:49
-
-
Save lscoates/2a080c3e33a2511e6617e391957130f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var phoneLabel = $('label[for="subscription_customer_attributes_phone"]'); | |
phoneLabel.text(phoneLabel.text() + " *"); | |
}); | |
var form = $("form:first"); | |
var phone = $("#subscription_customer_attributes_phone"); | |
var submitBtn = $("#subscription_submit") | |
submitBtn.click(function(){ | |
if (phone.val() === "") { | |
phone.addClass("field-error"); | |
return false; | |
} | |
}); | |
form.change(function() { | |
if (phone.val() != "") { | |
submitBtn.click(function() { | |
return true; | |
}); | |
} | |
}); | |
$("#subscription_customer_attributes_phone").blur(function() { | |
if ($(this).val() !== "") { | |
$(this).removeClass("field-error"); | |
} else { | |
$(this).addClass("field-error"); | |
} | |
}); | |
.field-error { | |
border-color: #ff0000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment