Validation Engine Returns False When Valid

Validation Engine is returning false when no errors were detected and true when validation is unsuccessful, which is the opposite of what I would expect. The weird part is that the tooltips are correct. Take a look at my example.

Try the Codepen here.

This appears to run counter to the Validation Engine documentation. 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)
  })
})

What did I do wrong?


This is apparently a known issue. The code base on GitHub includes unresolved issue #912 posted Feb. 1, 2016:

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.

Given the way the documentation is worded, I suspect this is actually a documentation issue rather than a code issue.

链接地址: http://www.djcxy.com/p/74982.html

上一篇: Angular2 Click方法总是返回false值

下一篇: 验证引擎有效时返回False