This is a migrated thread and some comments may be shown as answers.

TextBox requerid

1 Answer 199 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
Danny asked on 30 Sep 2020, 08:34 PM
How did you add the required option to a TextBox?
  i am trying to do this but it doesn't work
@ (Html.Kendo (). TextBox ()
                       .Name ("txtCodSRI")
                       .Placeholder ("001")
                       .Readonly (true)
                       .Value (@ country.CodSRI)
                       .HtmlAttributes (new {@required = "true"})
                       .HtmlAttributes (new {@class = "form-control"})
                       )

1 Answer, 1 is accepted

Sort by
0
Accepted
Anton Mironov
Telerik team
answered on 02 Oct 2020, 12:46 PM

Hello Danny,

Thank you for the provided code snippet.

In order to set the "required" attribute of the Kendo UI TextBox, try the following:

  1. Merge all the needed attributes in a single HtmlAttributes option.
  2. Use the required property and "Readonly()" method separately as they are mutually exclusive.

Here is an example of the approach above:

@(Html.Kendo ().TextBox ()
    .Name ("txtCodSRI")
    .Placeholder ("001")
    .HtmlAttributes (new {@class = "form-control", required = "true"})
 )
I hope this information helps.

 

Kind Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TextBox
Asked by
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Anton Mironov
Telerik team
Share this question
or