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

Number validation

1 Answer 90 Views
Globalization
This is a migrated thread and some comments may be shown as answers.
Stepochkin
Top achievements
Rank 1
Stepochkin asked on 20 May 2013, 08:21 AM
After the last update kendo ui web (2013.1.514) i get the error for the decimal type value.
Here are a few lines of code:

Site.Master
<script src="<%= Url.Content("~/Scripts/kendo/2013.1.514/jquery.min.js") %>"></script>
    <script src="<%= Url.Content("~/Scripts/kendo/2013.1.514/kendo.all.min.js") %>"></script>
    <script src="<%= Url.Content("~/Scripts/kendo/2013.1.514/kendo.aspnetmvc.min.js") %>"></script>
    <script src="<%= Url.Content("~/Scripts/kendo/2013.1.514/cultures/kendo.culture.ru-RU.min.js") %>"></script>
    <script src="<%= Url.Content("~/Scripts/kendo.modernizr.custom.js") %>"></script>
    <script type="text/javascript">
        //set culture of the Kendo UI
        kendo.culture("ru-RU");
    </script>
View
<a title="Сохранить (Ctrl + S)" class="k-button k-button-icontext" href="#" onclick="orderEditControlAction()" data-role="save"><span class="k-icon k-update"></span>Сохранить</a>
<form id="formOrderEdit" method="post">
        <%:Html.HiddenFor(m => m.OrderId) %>
        <%:Html.LabelFor(m => m.Order_Weight) %>
         <%:Html.EditorFor(m => m.Order_Weight) %>
         <%:Html.ValidationMessageFor(m => m.Order_Weight) %>
</form>
 
 
<script type="text/javascript">
    var validator = null;
    $(document).ready(function () {
        validator = $("#formOrderEdit").kendoValidator().data("kendoValidator");
    });
    function orderEditControlAction() {
         
        if (validator.validate()) {
            $.ajax({
                cache: false,
                type: "POST",
                url: "/Order/save",
                data: $('#formOrderEdit').serialize(),
                success: function (response, textStatus, jqXHR) {
                    //...
                },
                error: function (data) {
                    alert("Ошибка при выполнении сохранения!");
                }
            });
        }
        return false;
    }
</script>
Model
public class OrderEditViewModel
{
        [ScaffoldColumn(false)]
        Guid OrderId { get; set; }
 
        [DisplayName("Кол-во изделий в тоннах")]
        [UIHint("NumberDecimal")]
        decimal? Order_Weight { get; set; }
}
Edit template
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<decimal?>" %>
 
<%: Html.Kendo().NumericTextBoxFor(m => m)
       .Decimals(3)
       .Format("N3")
       .Step(0.001m)
       .Min(0)
       .HtmlAttributes(new { style = "width:100%" })
%>
Global.asax
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("ru-RU");
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ru-RU");
 
System.Web.Mvc.ModelBinders.Binders.Add(typeof(decimal?), new CultureAwareDecimalModelBinder());

When i try to submit this form i get validation error
Order_Weight is not valid.

I also notated that is success in IE9 (in IE10, Opera e FF work fine).


1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 May 2013, 07:56 AM
Hello Stepochkin,

 
There is a known issue regarding NumericTextBox and culture different than en-US. The problem is addressed in the last internal build (2013.1.517). Please give it a try and let me know how it goes.

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