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

TagHelper vs widget renderes invalid html

3 Answers 68 Views
TextArea
This is a migrated thread and some comments may be shown as answers.
m
Top achievements
Rank 1
m asked on 22 Mar 2021, 06:39 PM

Hi,

When adding a textarea to a form, I get different html rendered result:

 

<kendo-textarea name="reason-reject" rows="5" placeholder="Specify rejection reason" on-change="">
 
</kendo-textarea>
 
@(Html.Kendo().TextArea()
    .Name("invitation")
    .Placeholder("Enter your text here.")
    .Rows(10)
    .MaxLength(200)
    .HtmlAttributes(new { style = "width: 100%", required = true, data_required_msg = "Please enter a text.", data_max_msg= "Enter value between 1 and 200" })
    )

 

Even using the simple form of widget from the samples, generated invalid html.... Can you provide any guidance ?

Is is possible with taghelper, mark the control as mandatory ? 

Any help will be highly appreciated,

Manuel

 

3 Answers, 1 is accepted

Sort by
0
m
Top achievements
Rank 1
answered on 22 Mar 2021, 06:40 PM
image of rendered html
0
m
Top achievements
Rank 1
answered on 22 Mar 2021, 06:41 PM
image of rendered html
0
Anton Mironov
Telerik team
answered on 25 Mar 2021, 11:56 AM

Hello Manuel,

Thank you for the code snippet, image, and details provided.

In order to achieve the desired behavior, I prepared a sample project with the needed implementation included.

For validating an HTML TextArea try using a JavaScript function handler of the form submit "click" event. Get the TextArea with jQuery and if its value is an empty string - prevent the default behavior with the help of the "preventDefault" method and show an error message.

Make the needed tests locally with the attached project and let me know if further assistance is needed.

 

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
TextArea
Asked by
m
Top achievements
Rank 1
Answers by
m
Top achievements
Rank 1
Anton Mironov
Telerik team
Share this question
or