我正在使用asp.net mvc 3.到目前为止,我已经成功创建了一个日期选择器。目前我在视图中显示了以下代码显示的三个字段。
@Html.TextBoxFor(model => model.QuizNo, new{@class = "qno"})
@Html.TextBoxFor(model => model.Mark, new { @class = "mk" })
@Html.EditorFor(model => model.Pass, new { @class = "ps" })
最后一个具有布尔值。这是我在TextBoxes中更改或设置值的脚本。
<script type="text/javascript">
$(document).ready(function () {
var qn = $(".qno :input").val();
$(".mk").val(qn);
});
</script>
我正在测试这个以查看当我在QuizNo文本框上输入值时,我在Mark文本框中得到一个值。到目前为止,它不是从上面的代码发生的。
我是asp.net mvc 3中的新手,jquery想检查QuizNo中输入的值,如果它的134,144或156然后任何高于10的Mark值都是通过。
以下是输出的HTML代码。
<form action="/Home/CreateNewcert/4558" method="post"> <fieldset>
<legend>CPD Details</legend>
<table style="border:1px solid #ffffff;">
<tr>
<td width="30%" style="border:1px solid #ffffff;">
<div class="editor-label">
<label for="QuizNo">QuizNo</label>
</div>
<div class="editor-field">
<input class="qno" data-val="true" data-val-number="The field QuizNo must be a number." id="QuizNo" name="QuizNo" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="QuizNo" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="Received">Received</label>
</div>
<div class="editor-field">
<select class="list-box tri-state" id="Received" name="Received"><option selected="selected" value="">Not Set</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
<span class="field-validation-valid" data-valmsg-for="Received" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="DateReceived">DateReceived</label>
</div>
<div class="editor-field">
<input class="datefield" id="DateReceived" name="DateReceived" type="date" value="" />
<span class="field-validation-valid" data-valmsg-for="DateReceived" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="Paid">Paid</label>
</div>
<div class="editor-field">
<select class="list-box tri-state" id="Paid" name="Paid"><option selected="selected" value="">Not Set</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
<span class="field-validation-valid" data-valmsg-for="Paid" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="DatePaid">DatePaid</label>
</div>
<div class="editor-field">
<input class="datefield" id="DatePaid" name="DatePaid" type="date" value="" />
<span class="field-validation-valid" data-valmsg-for="DatePaid" data-valmsg-replace="true"></span>
</div>
</td>
<td width="30%" style="border:1px solid #ffffff;">
</td>
<td width="30%" style="border:1px solid #ffffff;">
<div class="editor-label">
<label for="Mark">Mark</label>
</div>
<div class="editor-field">
<input class="mk" id="Mark" name="Mark" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Mark" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="MarkDate">MarkDate</label>
</div>
<div class="editor-field">
<input class="datefield" id="MarkDate" name="MarkDate" type="date" value="" />
<span class="field-validation-valid" data-valmsg-for="MarkDate" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="Pass">Pass</label>
</div>
<div class="editor-field">
<select class="list-box tri-state" id="Pass" name="Pass"><option selected="selected" value="">Not Set</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
<span class="field-validation-valid" data-valmsg-for="Pass" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="Printed">Printed</label>
</div>
<div class="editor-field">
<select class="list-box tri-state" id="Printed" name="Printed"><option selected="selected" value="">Not Set</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
<span class="field-validation-valid" data-valmsg-for="Printed" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="PrintedDate">PrintedDate</label>
</div>
<div class="editor-field">
<input class="datefield" id="PrintedDate" name="PrintedDate" type="date" value="" />
<span class="field-validation-valid" data-valmsg-for="PrintedDate" data-valmsg-replace="true"></span>
</div>
<div class="editor-label">
<label for="AccreditationNo">AccreditationNo</label>
</div>
<div class="editor-field">
<input class="text-box single-line" data-val="true" data-val-number="The field AccreditationNo must be a number." id="AccreditationNo" name="AccreditationNo" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="AccreditationNo" data-valmsg-replace="true"></span>
</div>
</td></tr></table>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
</form>
答案 0 :(得分:0)
你应该试试这个。
<script type="text/javascript">
$(document).ready(function () {
$(".qno").keyUp(function(){
$(".mk").val($(this).val());
});
});
</script>