-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Validation] Validating Radio buttons #2501
Comments
Does |
When using inline validation, For a simple two choice radio selection with a default post value (hidden input) that results in three identical prompts, one for each radio and one for the hidden input. This method, while far more cumbersome, allows a single error prompt. |
@jlukic I am having the same issue, 'checked' is not recognizing the group radios not being checked. HTML: <div class="inline field">
<div class="ui radio checkbox">
<input name="invoice_type" type="radio" value="down-payment">
<label for="grand-total">Grand Total</label>
</div>
<div class="ui radio checkbox">
<input name="invoice_type" type="radio" value="down-payment">
<label for="name">Category Totals</label>
</div>
<div class="ui radio checkbox">
<input name="invoice_type" type="radio" value="down-payment">
<label for="name">Line Item Totals</label>
</div>
</div> jQuery: (function( $ ) {
$(function() {
//Semantic UI Form Validation Job - Create Invoice =========================
$('.ui.form.create-invoice-form').form(
{
invoiceType: {
identifier : 'invoice_type',
rules: [
{
type : 'checked',
prompt : 'Specify the type of invoice that you would like to create'
},
]
}
},
{
inline : true,
on : 'blur',
}
);
});
})(jQuery); |
For anyone posting code samples please make a JSFiddle and not just copy and paste code here. Otherwise I'm manually creating test cases for every bug I'm trying to evaluate & fix. It looks like there is a regression with #2505 as well.. This appears to be functioning correctly, albeit with peculiar formatting due to #2505 regression |
There still seems to be some formatting issues with radio button validation when using inline errors. JSFiddle: http://jsfiddle.net/ebcn8xvq/2/ |
Thanks @Aproducktion! I used this technique for a group of checkboxes where atleast one needed to be checked. |
I see this is specifically an issue with |
What's up with the fix of this problem? |
Any progress? |
@dwightbcoder - thanks for the snippet. It would be nice to be able to add an additional validation call to the .on('change', '[type=radio]', function(e) {
const name = $(this).attr('name');
const hidden = $(`[type=hidden][name='${name}']`);
hidden.val($(this).val());
$('.ui.form').form('validate field', this.name);
}); This works for me. It relies on the field having the same name as the radio inputs. |
The validation on radio buttons seems to be working for me, as long as the type is set to 'checked' in the rules
|
It appears form validation does not include support for validating radio buttons so I have come up with a solution.
Nest your radio buttons into a field container with your default hidden input with an id you can target for validation:
Target your validation rules at the hidden input id:
Update the hidden input of the radio set with the checked value:
The text was updated successfully, but these errors were encountered: