1
我已啓用不顯眼的驗證。我的頁面源代碼看起來像這樣。驗證行爲與複選框和單選按鈕
<p>
<label>
Project Title
<br />
<input class="project-title" data-val="true" data-val-required="The Project Title field is required."
id="RequestDetail_ProjectTitle" name="RequestDetail.ProjectTitle" type="text"
value="" />
</label>
<span class="field-validation-valid" data-valmsg-for="RequestDetail.ProjectTitle"
data-valmsg-replace="true"></span> </p> <p>
<span>Submitted By</span><br />
<span class="inline-container">
<input type="hidden" id="RequestDetail_SubmittedBy" name="RequestDetail.SubmittedBy"
value="0" data-type="RequestDetail.SubmittedBy" /><label><input type="radio" data-type="RequestDetail.SubmittedBy"
name="_RequestDetail.SubmittedBy" value="1" data-val="true" data-val-required="The Submitted By field is required." />ND</label>
|
<label>
<input type="radio" data-type="RequestDetail.SubmittedBy" name="_RequestDetail.SubmittedBy"
value="2" data-val="true" data-val-required="The Submitted By field is required." />NE</label>
|
<label>
<input type="radio" data-type="RequestDetail.SubmittedBy" name="_RequestDetail.SubmittedBy"
value="4" data-val="true" data-val-required="The Submitted By field is required." />WY</label>
|
<label>
<input type="radio" data-type="RequestDetail.SubmittedBy" name="_RequestDetail.SubmittedBy"
value="8" data-val="true" data-val-required="The Submitted By field is required." />CL</label>
</span><span class="field-validation-valid" data-valmsg-for="_RequestDetail.SubmittedBy"
data-valmsg-replace="true"></span> </p> <p>
<span>Affected Plans</span><br />
<span class="inline-container">
<input type="hidden" id="RequestDetail_AffectedPlans" name="RequestDetail.AffectedPlans"
value="0" data-type="RequestDetail.AffectedPlans" /><label><input type="checkbox"
data-type="RequestDetail.AffectedPlans" name="_RequestDetail.AffectedPlans" value="1"
data-val="true" data-val-required="The Affected Plans field is required." />ND</label>
|
<label>
<input type="checkbox" data-type="RequestDetail.AffectedPlans" name="_RequestDetail.AffectedPlans"
value="2" data-val="true" data-val-required="The Affected Plans field is required." />NE</label>
|
<label>
<input type="checkbox" data-type="RequestDetail.AffectedPlans" name="_RequestDetail.AffectedPlans"
value="4" data-val="true" data-val-required="The Affected Plans field is required." />WY</label>
</span><span class="field-validation-valid" data-valmsg-for="_RequestDetail.AffectedPlans"
data-valmsg-replace="true"></span> </p>
以下是驗證時的輸出。
我申請的一切與單選按鈕,並在此顯示的複選框以同樣的方式。但是爲什麼我沒有在複選框中得到驗證錯誤,而我在單選按鈕中獲得了我的預期。
不錯。讓我嘗試一下。 – SaravananArumugam 2012-08-02 20:10:36