Changeset 1559

Show
Ignore:
Timestamp:
04/14/06 18:08:06 (7 years ago)
Author:
mheydon1973
Message:

Added form validation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.1/ivr/page.ivr.php

    r1348 r1559  
    107107<?php  
    108108?> 
    109         <form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"
     109        <form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return prompt_onsubmit();"
    110110        <input type="hidden" name="action" value="edited" /> 
    111111        <input type="hidden" name="display" value="ivr" /> 
     
    170170 
    171171        <tr><td colspan=2><hr /></td></tr> 
    172   <tr><td colspan=2> 
    173   <input name="increase" type="submit" value="<?php echo _("Increase Options")?>"></h6> 
     172  <tr><td colspan=2>  
     173  <input name="increase" type="submit" value="<?php echo _("Increase Options")?>"> 
    174174  &nbsp; 
    175   <input name="Submit" type="submit" value="<?php echo _("Save")?>"></h6> 
     175  <input name="Submit" type="submit" value="<?php echo _("Save")?>"> 
    176176  &nbsp; 
    177   <input name="decrease" type="submit" value="<?php echo _("Decrease Options")?>"></h6> 
     177  <?php if ($nbroptions > 1) { ?> 
     178  <input name="decrease" type="submit" value="<?php echo _("Decrease Options")?>"> 
     179  <?php } ?> 
    178180  </td></tr> 
    179181        <tr><td colspan=2><hr /></td></tr> 
     
    202204  }  
    203205?> 
    204   <input name="increase" type="submit" value="<?php echo _("Increase Options")?>"></h6> 
     206  <input name="increase" type="submit" value="<?php echo _("Increase Options")?>"> 
    205207  &nbsp; 
    206   <input name="Submit" type="submit" value="<?php echo _("Save")?>"></h6> 
     208  <input name="Submit" type="submit" value="<?php echo _("Save")?>"> 
    207209  &nbsp; 
    208   <input name="decrease" type="submit" value="<?php echo _("Decrease Options")?>"></h6> 
     210  <?php if ($nbroptions > 1) { ?> 
     211  <input name="decrease" type="submit" value="<?php echo _("Decrease Options")?>"> 
     212  <?php } ?> 
     213   
     214  <script language="javascript"> 
     215  <!-- 
     216   
     217  var theForm = document.prompt; 
     218   
     219  function prompt_onsubmit() { 
     220    var msgInvalidOption = "<?php echo _("Invalid option"); ?>"; 
     221     
     222    defaultEmptyOK = true; 
     223 
     224    // go thru the form looking for options 
     225    // where the option isn't blank (as that will be removed) do the validation 
     226      var allelems = theForm.elements; 
     227        if (allelems != null) 
     228        { 
     229          var i, elem; 
     230            for (i = 0; elem = allelems[i]; i++) 
     231            { 
     232              if (elem.type == 'text' && elem.name.indexOf('option') == 0) 
     233                { 
     234                  if (elem.value != '') { 
     235                      if (!isIVROption(elem.value)) 
     236                          return warnInvalid(elem, msgInvalidOption); 
     237                         
     238                        var gotoNum = elem.name.charAt(6); 
     239                        var isok = validateSingleDestination(theForm,gotoNum,true); 
     240                        if (!isok) 
     241                          return false; 
     242                    } 
     243                 } 
     244            } 
     245        } 
     246                                 
     247    return true; 
     248  } 
     249   
     250  //--> 
     251  </script> 
    209252        </form> 
    210253        </div> 
     
    229272} 
    230273 
    231  
     274/* this should be in /admin/functions.inc.php 
    232275function runModuleSQL($moddir,$type){ 
    233276        global $db; 
     
    254297} 
    255298 
    256  
    257 ?> 
     299*/ 
     300 
     301?>