验证引擎 Returns 有效时为假
Validation Engine Returns False When Valid
验证引擎在未检测到错误时返回 false,在验证不成功时返回 true,这与我的预期相反。奇怪的是工具提示是正确的。看看我的例子。
这似乎运行 与验证引擎文档背道而驰。 According to the Validation Engine Docs:
validate
Validates a form or field, displays error prompts accordingly.
Returns true if the form validates, false if it contains errors.
For fields, it returns true on validate and false on errors.
When using form validation with ajax, it returns undefined , the result is delivered asynchronously via function options.onAjaxFormComplete.
alert( $("#formID1").validationEngine('validate') );
alert( $("#emailInput").validationEngine('validate') );
HTML
<div>
<input type="text" name="billLast_Name"
class="form-control bill-field validate[required]"
placeholder="Surname*"
value=""
title="Surname"/>
<button id="validate">Validate</button>
<div id="result"></div>
</div>
jQuery
$(document).ready(function(){
$('#validate').on('click', function(){
var result = $('.bill-field').validationEngine('validate')
$('#result').html('Validation result is ' + result)
})
})
我做错了什么?
这显然是一个已知问题。 code base on GitHub includes unresolved issue #912 2016 年 2 月 1 日发布:
In documentation:
validate
Validates a form or field, displays error prompts accordingly.
Returns true if the form validates, false if it contains errors. (correct)
For fields, it returns true on validate and false on errors. (wrong)
This is actually the other way. On validate it returns false and errors it returns true.
鉴于文档的措辞方式,我怀疑这实际上是文档问题而不是代码问题。
验证引擎在未检测到错误时返回 false,在验证不成功时返回 true,这与我的预期相反。奇怪的是工具提示是正确的。看看我的例子。
这似乎运行 与验证引擎文档背道而驰。 According to the Validation Engine Docs:
validate
Validates a form or field, displays error prompts accordingly.
Returns true if the form validates, false if it contains errors. For fields, it returns true on validate and false on errors. When using form validation with ajax, it returns undefined , the result is delivered asynchronously via function options.onAjaxFormComplete.
alert( $("#formID1").validationEngine('validate') );
alert( $("#emailInput").validationEngine('validate') );
HTML
<div>
<input type="text" name="billLast_Name"
class="form-control bill-field validate[required]"
placeholder="Surname*"
value=""
title="Surname"/>
<button id="validate">Validate</button>
<div id="result"></div>
</div>
jQuery
$(document).ready(function(){
$('#validate').on('click', function(){
var result = $('.bill-field').validationEngine('validate')
$('#result').html('Validation result is ' + result)
})
})
我做错了什么?
这显然是一个已知问题。 code base on GitHub includes unresolved issue #912 2016 年 2 月 1 日发布:
In documentation:
validate
Validates a form or field, displays error prompts accordingly.
Returns true if the form validates, false if it contains errors. (correct)
For fields, it returns true on validate and false on errors. (wrong)This is actually the other way. On validate it returns false and errors it returns true.
鉴于文档的措辞方式,我怀疑这实际上是文档问题而不是代码问题。