Skip to content

Instantly share code, notes, and snippets.

@jonmunson
Created November 4, 2013 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonmunson/7301706 to your computer and use it in GitHub Desktop.
Save jonmunson/7301706 to your computer and use it in GitHub Desktop.
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