Haloo,我这里有问题
我的验证脚本
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['product']['option'][$product_option['product_option_id']]
= sprintf($this->language->get('error_required'), $product_option['name']);
}
}
它是我的Div Id
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
目前,该剧本只是出现了#34; fieldname是必需的!&#34; 我希望它专注于空的必填字段,并显示&#34;字段名是必需的!&#34;文字,谢谢
答案 0 :(得分:0)
当您检测到错误时,输出将焦点设置在无效字段上的Javascript。
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['product']['option'][$product_option['product_option_id']]
= sprintf($this->language->get('error_required'), $product_option['name']);
?>
<script>
$(function () {
$("#option-<?php echo $product_option['product_option_id'] ?> input").focus();
});
</script>
<?php
}
}