在几年前由其他开发人员制作的ExpressionEngine模板页面中,我们有以下形式:
<div id="sidebar_loader" class="dnone">
<div class="sb-bg">
<div class="sb-bg-bottom">
<h2 class="findloc">Find Location Nearest You</h2>
<span class="findloc-content">
To find your nearest Carriage Services location enter your <b>City
and State</b> or your <b>ZIP code</b>.
</span>
<div class="hbar w280px"></div>
<div class="searchContent">
<div class="searching">Now Searching for the closest locations to you.</div>
<div class="hbar w280px"></div>
</div>
</div>
</div><!-- /sb-bg end -->
</div><!-- /sidebar_loader end -->
<div id="sidebar">
<div class="sb-bg">
<div class="sb-bg-bottom">
<h2 class="findloc">Find Location Nearest You</h2>
<span class="findloc-content">
To find your nearest Carriage Services location enter your <b>City
and State</b> or your <b>ZIP code</b>.
</span>
<div class="hbar w280px"></div>
<div class="search_row">
<div class="search_caption">Zip Code</div>
<input type="text" id="address" class="textbox" name="address" value="{exp:mx_google_map:searched_zip}" />
</div>
<br class="clear">
<div class="search_row">
<div class="search_caption">Distance</div>
<div class="selCont">
<?php
$selected = "{exp:mx_google_map:searched_radius1}";
if($selected == "")
{
$selected = "30";
}
?>
<select name="radius1" id="fradius">
<option value="10" <?php if ( $selected == "10") echo "selected='selected'"; ?>>10 MILES</option>
<option value="15" <?php if ( $selected == "15") echo "selected='selected'"; ?>>15 MILES</option>
<option value="20" <?php if ( $selected == "20") echo "selected='selected'"; ?>>20 MILES</option>
<option value="25" <?php if ( $selected == "25") echo "selected='selected'"; ?>>25 MILES</option>
<option value="31" <?php if ( $selected == "31") echo "selected='selected'"; ?>>30 MILES</option>
<option value="50" <?php if ( $selected == "50") echo "selected='selected'"; ?>>50 MILES</option>
<option value="100" <?php if ( $selected == "100") echo "selected='selected'"; ?>>100 MILES</option>
</select>
</div>
</div>
<div class="search_row" style="position:relative;">
<span style="position:absolute;top:-10px;left:120px;font-weight:bold;font-size:16px;color:#313131;#top:5px;">or</span>
<div class="hbar w280px"></div>
</div>
<br class="clear">
<div class="search_row">
<div class="search_caption">City</div>
<input type="text" id="city" class="textbox" name="city" value="{exp:mx_google_map:searched_city}"/>
</div>
<br class="clear">
<div class="search_row">
<div class="search_caption">State</div>
<div class="selCont state" id="Sstate">
<?php
$selectedState = "{exp:mx_google_map:searched_state}";
?>
<select id="state" name="state" >
<option value="AL" <?php if ( $selectedState == "AL") echo "selected='selected'"; ?>> Alabama</option>
<option value="AK" <?php if ( $selectedState == "AK") echo "selected='selected'"; ?>>Alaska</option>
<option value="AZ" <?php if ( $selectedState == "AZ") echo "selected='selected'"; ?>>Arizona</option>
<option value="AR" <?php if ( $selectedState == "AR") echo "selected='selected'"; ?>>Arkansas</option>
<option value="CA" <?php if ( $selectedState == "CA") echo "selected='selected'"; ?>>California</option>
<option value="CO" <?php if ( $selectedState == "CO") echo "selected='selected'"; ?>>Colorado</option>
<option value="CT" <?php if ( $selectedState == "CT") echo "selected='selected'"; ?>>Connecticut</option>
<option value="DE" <?php if ( $selectedState == "DE") echo "selected='selected'"; ?>>Delaware</option>
<option value="FL" <?php if ( $selectedState == "FL") echo "selected='selected'"; ?>>Florida</option>
<option value="GA" <?php if ( $selectedState == "GA") echo "selected='selected'"; ?>>Georgia</option>
<option value="HI" <?php if ( $selectedState == "HI") echo "selected='selected'"; ?>>Hawaii</option>
<option value="ID" <?php if ( $selectedState == "ID") echo "selected='selected'"; ?>>Idaho</option>
<option value="IL" <?php if ( $selectedState == "IL") echo "selected='selected'"; ?>>Illinois</option>
<option value="IN" <?php if ( $selectedState == "IN") echo "selected='selected'"; ?>>Indiana</option>
<option value="IA" <?php if ( $selectedState == "IA") echo "selected='selected'"; ?>>Iowa</option>
<option value="KS" <?php if ( $selectedState == "KS") echo "selected='selected'"; ?>>Kansas</option>
<option value="KY" <?php if ( $selectedState == "KY") echo "selected='selected'"; ?>>Kentucky</option>
<option value="LA" <?php if ( $selectedState == "LA") echo "selected='selected'"; ?>>Louisiana</option>
<option value="ME" <?php if ( $selectedState == "ME") echo "selected='selected'"; ?>>Maine</option>
<option value="MD" <?php if ( $selectedState == "MD") echo "selected='selected'"; ?>>Maryland</option>
<option value="MA" <?php if ( $selectedState == "MA") echo "selected='selected'"; ?>>Massachusetts</option>
<option value="MI" <?php if ( $selectedState == "MI") echo "selected='selected'"; ?>>Michigan</option>
<option value="MN" <?php if ( $selectedState == "MN") echo "selected='selected'"; ?>>Minnesota</option>
<option value="MS" <?php if ( $selectedState == "MS") echo "selected='selected'"; ?>>Mississippi</option>
<option value="MO" <?php if ( $selectedState == "MO") echo "selected='selected'"; ?>>Missouri</option>
<option value="MT" <?php if ( $selectedState == "MT") echo "selected='selected'"; ?>>Montana</option>
<option value="NE" <?php if ( $selectedState == "NE") echo "selected='selected'"; ?>>Nebraska</option>
<option value="NV" <?php if ( $selectedState == "NV") echo "selected='selected'"; ?>>Nevada</option>
<option value="NH" <?php if ( $selectedState == "NH") echo "selected='selected'"; ?>>New Hampshire</option>
<option value="NJ" <?php if ( $selectedState == "NJ") echo "selected='selected'"; ?>>New Jersey</option>
<option value="NM" <?php if ( $selectedState == "NM") echo "selected='selected'"; ?>>New Mexico</option>
<option value="NY" <?php if ( $selectedState == "NY") echo "selected='selected'"; ?>>New York</option>
<option value="NC" <?php if ( $selectedState == "NC") echo "selected='selected'"; ?>>North Carolina</option>
<option value="ND" <?php if ( $selectedState == "ND") echo "selected='selected'"; ?>>North Dakota</option>
<option value="OH" <?php if ( $selectedState == "OH") echo "selected='selected'"; ?>>Ohio</option>
<option value="OK" <?php if ( $selectedState == "OK") echo "selected='selected'"; ?>>Oklahoma</option>
<option value="OR" <?php if ( $selectedState == "OR") echo "selected='selected'"; ?>>Oregon</option>
<option value="PA" <?php if ( $selectedState == "PA") echo "selected='selected'"; ?>>Pennsylvania</option>
<option value="RI" <?php if ( $selectedState == "RI") echo "selected='selected'"; ?>>Rhode Island</option>
<option value="SC" <?php if ( $selectedState == "SC") echo "selected='selected'"; ?>>South Carolina</option>
<option value="SD" <?php if ( $selectedState == "SD") echo "selected='selected'"; ?>>South Dakota</option>
<option value="TN" <?php if ( $selectedState == "TN") echo "selected='selected'"; ?>>Tennessee</option>
<option value="TX" <?php if ( $selectedState == "TX") echo "selected='selected'"; ?>>Texas</option>
<option value="UT" <?php if ( $selectedState == "UT") echo "selected='selected'"; ?>>Utah</option>
<option value="VT" <?php if ( $selectedState == "VT") echo "selected='selected'"; ?>>Vermont</option>
<option value="VA" <?php if ( $selectedState == "V A") echo "selected='selected'"; ?>>Virginia</option>
<option value="WA" <?php if ( $selectedState == "WA") echo "selected='selected'"; ?>>Washington</option>
<option value="WV" <?php if ( $selectedState == "WV") echo "selected='selected'"; ?>>West Virginia</option>
<option value="WI" <?php if ( $selectedState == "WI") echo "selected='selected'"; ?>>Wisconsin</option>
<option value="WY" <?php if ( $selectedState == "WY") echo "selected='selected'"; ?>>Wyoming</option>
</select>
</div>
</div>
<div class="search_row">
<div class="search_caption">Distance</div>
<div class="selCont">
<?php
$selected = "{exp:mx_google_map:searched_radius2}";
if($selected == "")
{
$selected = "30";
}
?>
<select name="radius2" id="radius">
<option value="10" <?php if ( $selected == "10") echo "selected='selected'"; ?>>10 MILES</option>
<option value="15" <?php if ( $selected == "15") echo "selected='selected'"; ?>>15 MILES</option>
<option value="20" <?php if ( $selected == "20") echo "selected='selected'"; ?>>20 MILES</option>
<option value="25" <?php if ( $selected == "25") echo "selected='selected'"; ?>>25 MILES</option>
<option value="31" <?php if ( $selected == "31") echo "selected='selected'"; ?>>30 MILES</option>
<option value="50" <?php if ( $selected == "50") echo "selected='selected'"; ?>>50 MILES</option>
<option value="100" <?php if ( $selected == "100") echo "selected='selected'"; ?>>100 MILES</option>
</select>
</div>
</div>
<br class="clear">
<?php
$funeral = "{exp:mx_google_map:searchBy_Funeral}";
if( $funeral == "" )
{
$funeral = 0;
}
$cemetaries = "{exp:mx_google_map:searchBy_Cemetaries}";
if( $cemetaries == "" )
{
$cemetaries = 3;
}
?>
<div class="hbar w280px"></div>
<div class="search_row">
<span>Search For:</span>
<div id="funeral" class="check">Funeral Homes</div>
<div id="cemetaries" class="check">Cemeteries</div>
<input type="hidden" name="funeral" value="<?php echo $funeral; ?>" id="fhidden">
<input type="hidden" name="cemetaries" value="<?php echo $cemetaries; ?>" id="chidden">
<span><input type="image" src="/images/search.png" style="margin:20px 0 -20px 170px;" onclick="loader()"/></span>
</div>
<br class="clear">
</div>
</div><!-- /sb-bg end -->
</div><!-- /sidebarend -->
需要对其进行修改,以便在城市和邮政编码字段都为空时无效。至少有一个必须填补。不确定如何使用ExpressionEngine执行此操作。我的javascript和PHP不太好。
有人可以建议实施此验证的好方法吗?