0

私のアプリケーションには、ユーザーの詳細を編集できるページがあります。この情報の一部は検証され、一部のフィールドは必須であり、その他のフィールドは必須ではないことが確認されます。無効なエントリが入力されると、次の検証メッセージが表示されます。

http://gyazo.com/693fefaa64693ebbddbe1484f9b20cb8

これは、英語ロケールで作業する場合には問題ありませんが、Web サイトはスウェーデン語でも実行され、フォームは次のように表示されます。

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 に答える