I have a form with a select box and a input field: when option value of select is "8" I would have that input field must be less than 250
选择框
<select id="select_5" size="1" title="Effettua una scelta!" name="tipo_nolavorazioni" onChange="updatethis(this.form);">
<option value="8"> A </option>
<option value="1"> B</option>
<option value="2"> C</option>
<option value="3"> D </option>
</select>
输入框
<input class="required validate-number" maxlength="150" size="5" id="text_2" name="base" type="text" onChange="updatethis(this.form);" value="" />
<p id="errore_base"></p>
在 JS 文件中,我添加了以下内容:
function updatethis(form) {
if (tipo1==8) {
window.addEvent('domready', function(){
var valid = new LiveValidation('text_2', {insertAfterWhatNode : "errore_base"});
valid.add(Validate.Numericality, { maximum: 250, tooHighMessage: "Max 250cm" });
});
}
}
这可行,但如果我更改选项值(例如 B=1).. 错误消息仍然存在,我无法处理我的表单。我哪里错了?