function checkRequiredFields( alertMsg ) {
  // check the inputs of all single-value requiredFields
  var returnVal = true;
  $( "input:visible", ".requiredField" ).each( function() {
    if( !this.value || this.value == "" ) {
      alert( alertMsg );
      returnVal = false;
    }
  } );
  
  if( returnVal == false ) {
    return false;
  }
  
  // check the inputs of all multi-value requiredFields
  var multiAlert = true;
  var showMultiAlert = false;
  $( "input:visible", ".requiredField_multi" ).each( function() {
    showMultiAlert = true;
    if( this.value && this.value != "" ) {
      multiAlert = false;
    }
  } );
  
  if( multiAlert && showMultiAlert ) {
    alert( alertMsg );
    return false;
  }
  //If electronic citation check if at least one url is supplied
  if($('#type_selector').val() == 'electronic'){
    var showUrlAlert = $("input:text[name^='url_']" ).filter(function(){
                        return this.value.trim().length;
                        }).length > 0;
    if(!showUrlAlert){
      alert( "Must supply at least one url for electronic citation." );
      return false;
    }
  }
  return true;
}
/**
 * Check required fields on create and edit pages
 *
 */
Check required fields on create and edit pages
Check required fields on create and edit pages
function checkRequiredFields( alertMsg ) {
  var returnVal = true;
  $( "input:visible", ".requiredField" ).each( function() {
    if( !this.value || this.value == "" ) {
      alert( alertMsg );
      returnVal = false;
    }
  } );
  if( returnVal == false ) {
    return false;
  }
  var multiAlert = true;
  var showMultiAlert = false;
  $( "input:visible", ".requiredField_multi" ).each( function() {
    showMultiAlert = true;
    if( this.value && this.value != "" ) {
      multiAlert = false;
    }
  } );
  if( multiAlert && showMultiAlert ) {
    alert( alertMsg );
    return false;
  }
  if($('#type_selector').val() == 'electronic'){
    var showUrlAlert = $("input:text[name^='url_']" ).filter(function(){
                        return this.value.trim().length;
                        }).length > 0;
    if(!showUrlAlert){
      alert( "Must supply at least one url for electronic citation." );
      return false;
    }
  }
  return true;
}
function checkRequiredFields ( alertMsg ) { var returnVal = true ; $ ( "input:visible" , ".requiredField" ) . each ( function ( ) { if ( ! this . value || this . value == "" ) { alert ( alertMsg ) ; returnVal = false ; } } ) ; if ( returnVal == false ) { return false ; } var multiAlert = true ; var showMultiAlert = false ; $ ( "input:visible" , ".requiredField_multi" ) . each ( function ( ) { showMultiAlert = true ; if ( this . value && this . value != "" ) { multiAlert = false ; } } ) ; if ( multiAlert && showMultiAlert ) { alert ( alertMsg ) ; return false ; } if ( $ ( '#type_selector' ) . val ( ) == 'electronic' ) { var showUrlAlert = $ ( "input:text[name^='url_']" ) . filter ( function ( ) { return this . value . trim ( ) . length ; } ) . length > 0 ; if ( ! showUrlAlert ) { alert ( "Must supply at least one url for electronic citation." ) ; return false ; } } return true ; }
Check required fields on create and edit pages
Check required fields on create and edit pages
// check the inputs of all single-value requiredFields // check the inputs of all multi-value requiredFields //If electronic citation check if at least one url is supplied