在我的应用程序中,我们有一个页面,我们可以编辑用户的详细信息。其中一些信息经过验证可确保某些字段是必需的,而其他字段则不需要。输入无效条目时,我们会看到以下验证消息:
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 <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 <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 <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 <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>
在不同文化中使用验证时,我是否缺少某些内容?我感谢任何和所有的回应,我真的很难过!提前谢谢。
答案 0 :(得分:0)
好的,最后它非常简单,只是在代码中呈现瑞典字符的方式。一些特殊字符必须干扰JavaScript并阻止其运行。只需跟踪麻烦的提取物。干杯!