我从 Joomla 组件 Vik Rent Cars 中创建了一个自定义字段,自定义字段的 id 是“vrcf13”。我怎样才能让它只接受 8 个数字?
代码是:
<table class="vrccustomfields">
<?php
$currentUser = JFactory::getUser();
$juseremail = !empty($currentUser->email) ? $currentUser->email : "";
foreach ($cfields as $cf) {
if (intval($cf['required']) == 1) {
$isreq = "<span class=\"vrcrequired\"><sup>*</sup></span> ";
} else {
$isreq = "";
}
if (!empty ($cf['poplink'])) {
$fname = "<a href=\"" . $cf['poplink'] . "\" id=\"vrcf" . $cf['id'] . "\" rel=\"{handler: 'iframe', size: {x: 750, y: 600}}\" target=\"_blank\" class=\"modal\">" . JText :: _($cf['name']) . "</a>";
} else {
$fname = "<span id=\"vrcf" . $cf['id'] . "\">" . JText :: _($cf['name']) . "</span>";
}
if ($cf['type'] == "text") {
$textmailval = intval($cf['isemail']) == 1 ? $juseremail : "";
?>
<tr><td align="right"><?php echo $isreq; ?><?php echo $fname; ?> </td><td><input type="text" name="vrcf<?php echo $cf['id']; ?>" value="<?php echo $textmailval; ?>" size="40" class="vrcinput"/></td></tr>
<?php
}elseif ($cf['type'] == "textarea") {
?>
<tr><td valign="top" align="right"><?php echo $isreq; ?><?php echo $fname; ?> </td><td><textarea name="vrcf<?php echo $cf['id']; ?>" rows="5" cols="30" class="vrctextarea"></textarea></td></tr>
<?php
}elseif ($cf['type'] == "date") {
?>
<tr><td valign="top" align="right"><?php echo $isreq; ?><?php echo $fname; ?> </td><td><?php echo JHTML::_('calendar', '', 'vrcf'.$cf['id'], 'vrcf'.$cf['id'].'date', $nowdf, array('class'=>'vrcinput', 'size'=>'10', 'maxlength'=>'19')); ?></td></tr>
<?php
}elseif ($cf['type'] == "select") {
$answ = explode(";;__;;", $cf['choose']);
$wcfsel = "<select name=\"vrcf" . $cf['id'] . "\">\n";
foreach ($answ as $aw) {
if (!empty ($aw)) {
$wcfsel .= "<option value=\"" . $aw . "\">" . $aw . "</option>\n";
}
}
$wcfsel .= "</select>\n";
?>