-1

我正在使用 asp.net mvc 3。到目前为止,我已经设法创建了一个 datepicker。目前,我认为下面的代码显示了三个字段。

   @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>
4

1 回答 1

0

你应该试试这个。

<script type="text/javascript">
$(document).ready(function () {
 $(".qno").keyUp(function(){
   $(".mk").val($(this).val());
 });
});
</script>
于 2012-12-13T09:46:37.797 回答