Skip to content

[Validation] Custom radio button form validation receive wrong value #6194

Open
@joshuaavalon

Description

@joshuaavalon

Version: 2.3.0
Example: https://jsfiddle.net/hpofx6qv/

Expect:

  • "yes" when Yes is selected.
  • "no" when No is selected.
  • false when nothing is selected.

Result:

  • All return "yes"
<form class="ui form">
  <div class="inline fields">
    <div class="field">
        <div class="ui radio checkbox">
            <input type="radio" name="note" tabindex="0" class="hidden" id="noteYes" value="yes">
            <label for="noteYes">Yes</label>
        </div>
    </div>
    <div class="field">
        <div class="ui radio checkbox">
            <input type="radio" name="note" tabindex="0" class="hidden" id="noteNo" value="no">
            <label for="noteNo">No</label>
        </div>
    </div>
</div>
<div class="ui button" id="valid">Valid</div>
<div id="result"></div>
</form>
 $.fn.form.settings.rules.isYes = function (value) {
            $("#result").text(value);
            return value === "yes";
 };

$(".ui.form").form({
    fields: {
        note: {
            identifier: "note",
            rules: [{
                type: "isYes",
                prompt: "Not yes"
            }]
        }
    }
});

$("#valid").click(function() {
	$(".ui.form").form("validate form");
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions