0

在我的应用程序中,我们有一个页面,我们可以在其中编辑用户的详细信息。其中一些信息经过验证,以确保某些字段是必需的,而另一些则不是。当输入无效条目时,我们会看到以下验证消息:

http://gyazo.com/693fefaa64693ebbddbe1484f9b20cb8

在英语语言环境中工作时这很好,但是该网站也以瑞典语运行,并且表单显示如下:

http://gyazo.com/7a426e503dc7243b68cba0b41fe7509d

到目前为止一切都很好,但是当我们提交带有空字段的表单时,验证被绕过并且条目被发送出去,并带有以下消息:

http://gyazo.com/4bd7922485e0df603212583aea8bdf8c

我相信“数据已更新”。对于我的一生,我无法确定这个问题的原因。请参阅下面的页面脚本中的表单验证:

    $("#edit_owner_form").validate({
        onfocusout: function(element)
        {
            //do nothing on focus out
        },
        onkeyup:function()
        {
           //do nothing on keyup
        },
        submitHandler: function (form) {
        return true;
        },
        rules: {
            Website: { url: true },
            TransactionRetentionPeriodInDays: { number: true },
            Company: { required: true },
            City: { required: true },
            Country: { required: true },
            PhoneNumber: { required: true }
        },
        messages: {
            Company: { required: COMPANY_NAME_REQUIRED },
            City: { required: TOWN_CITY_REQUIRED },
            Country: { required: COUNTRY_REQUIRED },
            PhoneNumber: { required: PHONENUMBER_REQUIRED },
            Website: { url: WEBSITE_REQUIRED }
        },
        errorPlacement: function (error, element) {
            error.appendTo($('#errorbox'));
            $("#errorbox label").css("color","#B94A48;");
            $("#ownerdetail").show();
            },

    });

所有消息都是预定义的变量,它们选择了正确的文化,但在任何时候都不会显示。我还将提供表格本身以供参考:

<form id="edit_owner_form">
<div class="container" id="ownerDetails">
    <input type="hidden" name="OwnerId" id="OwnerId" value="@Model.OwnerId" />
    <table>
        <tr style="vertical-align: top;">
            <td style="width: 300px; vertical-align: top;">
                <div id="left" style="vertical-align: top; clear: both; height: 470px;">
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.CompanyName&nbsp;<span class="reqd-field">*</span>
                    </div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="Company" id="Company" value="@Model.Company" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.Street</div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="Street" id="Street" value="@Model.Street" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.PostalZip</div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="PostalZIP" id="PostalZIP" value="@Model.PostalZIP" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.PhoneNumber&nbsp;<span class="reqd-field">*</span></div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="PhoneNumber" id="PhoneNumber" value="@Model.PhoneNumber" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.Website</div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="Website" id="Website" value="@Model.Website" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.GLN</div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="GLN" id="GLN" style="width: 260px;" value="@Model.GLN" /></div>
                    <br />
                </div>
            </td>
            <td style="width: 300px; vertical-align: top;">
                <div id="right" style="vertical-align: top; clear: both; height: 470px;">
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.Number</div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="Number" id="Number" value="@Model.Number" style="width:260px;" /></div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.TownCity&nbsp;<span class="reqd-field">*</span></div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="City" id="City" value="@Model.City" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.Country&nbsp;<span class="reqd-field">*</span></div>
                    <br />
                    <div class="editor-field">
                        @Html.DropDownListFor(model => model.Country, Model.AvailableCountries != null ? Model.AvailableCountries : new SelectList(new[] { "" }), new { id = "Country", name = "Country", style = "width:260px;height:30px !important;" })
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.FaxNumber</div>
                    <br />
                    <div class="editor-field">
                        <input type="text" name="FaxNumber" id="FaxNumber" value="@Model.FaxNumber" style="width:260px;" />
                    </div>
                    <br />
                    <div class="editor-label" style="font-weight: bold;">
                        @Language.Currency</div>
                    <br />
                    <div class="editor-field">
                        @Html.DropDownListFor(model => model.CurrencyCode_CurrencyCodeId, Model.CurrencyCodes != null ? Model.CurrencyCodes : new SelectList(new[] { "" }), new { id = "CurrencyCode_Code", style = "width:260px;height:30px !important;" })
                    </div>
                </div>
            </td>
        </tr>
    </table>
</div>
</form>

在不同文化中进行验证时,我是否遗漏了什么?我很感激任何和所有的回应,我真的很难过!提前致谢。

4

1 回答 1

0

好的,最后它相当简单,只是取决于瑞典语字符在代码中的呈现方式。一定是某些特殊字符干扰了 JavaScript 并阻止它运行。只是追踪麻烦的提取物的问题。干杯!

于 2013-05-15T16:26:34.657 回答