-
-
Save besimhu/9f2555df1110478fd2211f8880f10394 to your computer and use it in GitHub Desktop.
Radio button validation + iodine.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label for="password">Plan</label> | |
<input name="plan" type="radio" id="pro" value="pro" x-bind:class="{'invalid':plan.errorMessage}" data-rules='["requiredChoice:plan"]' data-server-errors='[]'> | |
<input name="plan" type="radio" id="basic" value="basic" x-bind:class="{'invalid':plan.errorMessage}" data-rules='["requiredChoice:plan"]' data-server-errors='[]'> | |
<p class="error-message" x-show.transition.in="plan.errorMessage" x-text="plan.errorMessage"></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iodine.addRule("requiredChoice", (value, name) => { | |
return document.querySelector('input[name="' + name + '"]:checked') != null; | |
}); | |
Iodine.messages.requiredChoice = "Please select one of these options"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment