Telerik Forums
UI for ASP.NET Core Forum
1 answer
72 views

Using custom validity as below...

@(Html.Kendo()
                        .TextBoxFor(m => m.Task)
                        .Value(null)
                        .HtmlAttributes(new
                        {
                            required = "required",
                            oninvalid = "this.setCustomValidity('Enter a task')",
                            oninput = "this.setCustomValidity('')"
                        })
                        )

I've tried to do the same for other controls (numeric textbox, datetime picker, autocomplete) but it doesn't work.

For example, when trying the same thing for numeric textbox, in console I get an error "An invalid form control with name='Advance' is not focusable.

@(Html.Kendo()
                    .NumericTextBoxFor(m => m.Advance)
                    .Min(0).Max(1000)
                    .HtmlAttributes(new
                    {
                        id = "advance",
                        required = "required",
                        oninvalid = "this.setCustomValidity('Enter a number')",
                        oninput = "this.setCustomValidity('')",
                    })
                    )
Mihaela
Telerik team
 answered on 09 Nov 2023
1 answer
263 views

I have a group of fields on a form.  It is OK if they are all empty, but if one in the group has data, they all must have data.  There are other fields with other validation rules that are not part of the group.

The fields are a combination of TimePicker, NumericTextBox, TextBox, MaskedTextBox, ComboBox and RadioButton.  The fields always appear in a group so they aren't spread out all over the form.

The values need to be checked before the form is saved.

What's the best way of checking for all fields null or not null and if they are not all null or all not null then display a message.  Ideally it would be nice to display which fields are missing.

I'm using the MVVM pattern

TIA

Narrow your results
Selected tags
Tags
+? more
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?