Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validation script to determine a "checkbox" state
//Validation for Sponsor in Application Edit/Show
function validate(){
var hasSponsor = document.getElementById('hasSponsor'); //check box ID
if (hasSponsor.checked){
sponsorUrl = document.getElementById('sponsorUrl'); //sponsor URL field ID
sponsorImage = document.getElementById('sponsorImage'); //sponsor Image field ID
if ( sponsorUrl == null || sponsorUrl == "" ) {
alert("You need to enter a Sponsor URL")
}
if ( sponsorImage == null || sponsorImage == "" ) {
alert("You need to specify a Sponsor Image")
}
console.log("There is a Sponsor!!!") ;
} else {
console.log("There is no Sponsor...")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment