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

NumericTextBox disappears from invalid form on post

1 Answer 148 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
C.P.A.M. Van Aaken
Top achievements
Rank 1
C.P.A.M. Van Aaken asked on 16 Oct 2014, 01:55 PM
Since the problem is quite complex, I have included a sample project in attachment to reproduce the problem. I had to leave out the downloaded NuGet packages, Content/kendo and Scripts/kendo to get the zip under 2 Mb. I thrust you can get it working again. If not, it is basically an MVC5 project with KendoUI added, a model, and some changes to the HomeController and its _Layout and Index views.

Due to the combination of Kendo UI NumericTextBox, jquery validation, server-side model validation, the numeric text box disapears.

Steps to reproduce with solution in attachment:
- Run the project ;-)
- Click Post
- Empty the non-Telerik textbox
- Click Post again
- Watch the NumericTextBox disappear.

My analysis so far:
- In the first postback, client-side validation doesn't find an error, but server side validation does (the NumericTextBox is required)
- Then, with the second postback, client-side validation does find an error with the non-Telerik textbox, but not with the NumericTextBox
- jQuery validation empties all spans with the class "input-validation-error", where it can no longer find a validation error
- the initialised NumericTextBox fits this description, so the span is emptied, making the NumericTextBox disappear.

My questions:
- Why doesn't the "Required" error get caught on client-side validation?
- How do we keep the described side effect from happening for cases where we verify certain business rules on server-side only?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Oct 2014, 11:29 AM
Hi,

I believe that the problem and its solution is described here. Let me know if I am missing something in current scenario.

As to the concrete question:
- Why doesn't the "Required" error get caught on client-side validation?

By default, jQuery validate (since v1.9) does not validate hidden elements. Refer to the shared article for more information.

- How do we keep the described side effect from happening for cases where we verify certain business rules on server-side only?

The troubleshooting section should give a feasible solution to this issue.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
NumericTextBox
Asked by
C.P.A.M. Van Aaken
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or