Changeset 9215

Show
Ignore:
Timestamp:
03/14/10 22:09:56 (2 years ago)
Author:
p_lindheimer
Message:

add validation for dialpartterns and make sure at least one entry re #4110

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.8/core/page.routing.php

    r9207 r9215  
    679679    changedClass: "text-red" 
    680680  }); 
    681   /*TODO: call clearPattern() here, or move this to routeEdit_onsubmit()? 
    682   */ 
    683   $("form").submit(function() { 
    684     $(this).find(".dpt-title").each(function() { 
    685       if($(this).val() == $(this).data("defText")) { 
    686         $(this).val(""); 
    687       } 
    688     }); 
    689   }); 
    690681});  
    691682 
     
    763754  var msgInvalidRouteName = "<?php echo _('Route name is invalid, please try again'); ?>"; 
    764755  var msgInvalidRoutePwd = "<?php echo _('Route password must be numeric or leave blank to disable'); ?>"; 
    765   var msgInvalidDialPattern = "<?php echo _('Dial pattern is invalid'); ?>"; 
    766756  var msgInvalidTrunkSelection = "<?php echo _('At least one trunk must be picked'); ?>"; 
    767757  var msgInvalidOutboundCID = "<?php echo _('Invalid Outbound Caller ID'); ?>"; 
     
    790780   
    791781  theForm.action.value = act; 
    792   return true; 
     782 
     783  clearPatterns(); 
     784  return validatePatterns(); 
    793785} 
    794786 
     
    799791    } 
    800792  }); 
     793  return true; 
     794} 
     795 
     796function validatePatterns() { 
     797  var one_good = false; 
     798  var culprit; 
     799  var msgInvalidDialPattern; 
     800  defaultEmptyOK = false; 
     801 
     802  $(".toggleval").each(function() { 
     803    if ($.trim($(this).val()) == '') { 
     804    } else if (!isDialpattern($(this).val())) { 
     805      culprit = this; 
     806      return false; 
     807    } else { 
     808      one_good = true; 
     809    } 
     810  }); 
     811 
     812  if (culprit == undefined && !one_good) { 
     813    culprit = $('.toggleval:visible').get(0); 
     814    msgInvalidDialPattern = "<?php echo _('No dial pattern, there must be at least one'); ?>"; 
     815  } else { 
     816    msgInvalidDialPattern = "<?php echo _('Dial pattern is invalid'); ?>"; 
     817  } 
     818  if (culprit != undefined) { 
     819    // now we have to put it back... 
     820    // do I have to turn it off first though? 
     821    $(".dpt-title").each(function() { 
     822      if ($.trim($(this).val()) == '') { 
     823        $(this).toggleVal({ 
     824          populateFrom: "title", 
     825          changedClass: "text-normal", 
     826          focusClass: "text-normal" 
     827        }); 
     828      } 
     829    }); 
     830    return warnInvalid(culprit, msgInvalidDialPattern); 
     831  } else { 
     832    return true; 
     833  } 
    801834} 
    802835 
     
    829862    document.getElementById('reporoutekey').value=key; 
    830863    document.getElementById('action').value='prioritizeroute'; 
     864    clearPatterns(); 
    831865    document.getElementById('routeEdit').submit(); 
    832866    break;