我有一个带有输入复选框的eloqua表格,带有liveValidation。 因此,复选框的错误消息显示在复选框旁边,而不是旁边的复选框和内容。
尝试了多种解决方法。
var field2 = new LiveValidation(dom1, {
validMessage: "OK!"
});
field2.add(Validate.Acceptance, {
failureMessage: "This field is required"
});
.LV_validation_message {
font-weight: bold;
margin: 0 0 0 5px;
}
.LV_valid {
color: #00CC00;
display: none;
}
.LV_invalid {
color: #8e0909;
font-size: 15px;
font-family: 'pp-sans-small-regular', Helvetica Neue, Arial, sans-serif;
font-weight: 500;
}
.LV_valid_field,
input.LV_valid_field:hover,
input.LV_valid_field:active,
textarea.LV_valid_field:hover,
textarea.LV_valid_field:active {
outline: 1px solid #00CC00;
}
.LV_invalid_field,
input.LV_invalid_field:hover,
input.LV_invalid_field:active,
textarea.LV_invalid_field:hover,
textarea.LV_invalid_field:active {
outline: 1px solid #8e0909;
}
<input id="field2" name="legalCheckbox" type="checkbox" value="check" class="legalCheckbox" />
<span class="signupCheck">{@pre type="content" key="checkbox.message" /}
<a href=https://www.paypal.com/us/webapps/mpp/ua/privacy-full class="signupPolicy">{@pre type="content" key="checkbox.condtions" /}</a>
</span>
答案 0 :(得分:1)
因为您在页面中没有任何ID dom1
,并且您以错误的方式使用了dom1
。它应该是一个字符串,如 "dom1"
。
此处您的输入ID为 field2 ,因此请使用field2
代替dom1
Stack Snippet
var field2 = new LiveValidation("field2", {
validMessage: "OK!",
onlyOnBlur: true
});
field2.add(Validate.Acceptance, {
failureMessage: "This field is required"
});
&#13;
.LV_validation_message {
font-weight: bold;
margin: 0 0 0 5px;
}
.LV_valid {
color: #00CC00;
display: none;
}
.LV_invalid {
color: #8e0909;
font-size: 15px;
font-family: 'pp-sans-small-regular', Helvetica Neue, Arial, sans-serif;
font-weight: 500;
}
.LV_valid_field,
input.LV_valid_field:hover,
input.LV_valid_field:active,
textarea.LV_valid_field:hover,
textarea.LV_valid_field:active {
outline: 1px solid #00CC00;
}
.LV_invalid_field,
input.LV_invalid_field:hover,
input.LV_invalid_field:active,
textarea.LV_invalid_field:hover,
textarea.LV_invalid_field:active {
outline: 1px solid #8e0909;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://secure.eloqua.com/Include/livevalidation_standalone.compressed.js" type="text/javascript"></script>
<input id="field2" name="legalCheckbox" type="checkbox" value="check" class="legalCheckbox" />
<span class="signupCheck">signupCheck</span>
&#13;
答案 1 :(得分:1)
LiveValidation函数包含一个名为insertAfterWhatNode
的属性。
LiveValidation引用的Documentation:
insertAfterWhatNode(可选) - {mixed} - 节点的引用或ID 之后插入消息(DEFAULT:正在出现的字段 验证)
id
代码中添加<span>
。insertAfterWhatNode
之后添加属性validMessage
,并在其中提供您的<span>
ID。您的代码应该类似于下面的代码段
var field2 = new LiveValidation("field2", {
validMessage: "OK!",
onlyOnBlur: true,
insertAfterWhatNode: "checkboxtext",
});
field2.add(Validate.Acceptance, {
failureMessage: "This field is required"
});
.LV_validation_message {
font-weight: bold;
margin: 0 0 0 5px;
}
.LV_valid {
color: #00CC00;
display: none;
}
.LV_invalid {
color: #8e0909;
font-size: 15px;
font-family: 'pp-sans-small-regular', Helvetica Neue, Arial, sans-serif;
font-weight: 500;
}
.LV_valid_field,
input.LV_valid_field:hover,
input.LV_valid_field:active,
textarea.LV_valid_field:hover,
textarea.LV_valid_field:active {
outline: 1px solid #00CC00;
}
.LV_invalid_field,
input.LV_invalid_field:hover,
input.LV_invalid_field:active,
textarea.LV_invalid_field:hover,
textarea.LV_invalid_field:active {
outline: 1px solid #8e0909;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://secure.eloqua.com/Include/livevalidation_standalone.compressed.js" type="text/javascript"></script>
<input id="field2" name="legalCheckbox" type="checkbox" value="check" class="legalCheckbox" />
<span class="signupCheck" id="checkboxtext">signupCheck</span>