Skip to content

funcCall validation not noticed with blank values #90

Closed
@medelibero

Description

@medelibero

I noticed a small bug with the funcCall validation. When using just the funcCall validation and testing for blank and returning a message it is not noticed by the validation handler. The reason this is done is in cases when blank values are not accepted on a condition of another field being selected. A contrived example is below:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>test</title>

    <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
    <script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>


    <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#testForm").validationEngine('attach', {promptPosition : "bottomLeft", scroll: false});
        });

        function validateTest(field, rules, i, options) {
            if(field.val() == "")
                return "This is from Custom Validator";
        }
    </script>
</head>
<body>
    <form id="testForm" name="testForm" method="post">
        <p>
            <label for="testJustCustom">Test With Just Custom: </label>
            <input type="text" name="testJustCustom" id="testJustCustom" class="validate[funcCall[validateTest]]">
        </p>

        <p>
            <label for="testWithRequiredAndCustom">Test With Required &amp; Custom Validator: </label>
            <input type="text" name="testWithRequiredAndCustom" id="testWithRequiredAndCustom" class="validate[required,funcCall[validateTest]]">
        </p>

        <input type="submit" value="Submit">
    </form>
</body>
</html>

Using this HTML if you do the following.

  1. Load the form into the browser click into "Test With Just Custom" field and then hit tab you will see no validation message and from what I see there should be.
  2. Using the same form if you click into "Test With Required & Custom Validator" and then tab out of it you should receive both validation errors (one from the required field validator and one from the custom validator).

Thanks!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions