猿问

WebForms UnobtrusiveValidationMode需要针对“ jquery”

我正在使用Visual Studio 2012构建Web应用程序。我试图将字数添加到文本框中。但是,在添加javascript代码和html代码之后。我收到上述错误。


这是我的JavaScript代码


代码:


function validateLimit(obj, divID, maxchar) {


objDiv = get_object(divID);


if (this.id) obj = this;


var remaningChar = maxchar - trimEnter(obj.value).length;


if (objDiv.id) {

    objDiv.innerHTML = remaningChar + " characters left";

}

if (remaningChar <= 0) {

    obj.value = obj.value.substring(maxchar, 0);

    if (objDiv.id) {

        objDiv.innerHTML = "0 characters left";

    }

    return false;

}

else

{ return true; }

}


function get_object(id) {

var object = null;

if (document.layers) {

    object = document.layers[id];

} else if (document.all) {

    object = document.all[id];

} else if (document.getElementById) {

    object = document.getElementById(id);

}

return object;

}


function trimEnter(dataStr) {

return dataStr.replace(/(\r\n|\r|\n)/g, "");

}

主页中的服务器代码


<script type="text/javascript" src="js/JScript.js" ></script>

ASPX代码,(HTML代码)


<tr>

<th style="width: 595px; height: 135px;">Official Report :</th>

<td colspan="4" style="height: 135px">

  <asp:TextBox ID="tbofficial" runat="server" Height="121px" TextMode="MultiLine" Width="878px" MaxLength="500"   ToolTip="Summary:(500 characters)" onkeyup="return validateLimit(this, 'lblMsg1', 500)" ></asp:TextBox>

  <div id="lblMsg1">500 characters left</div>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 

        ControlToValidate="tbofficial" Display="Dynamic" 

        SetFocusOnError="True">*</asp:RequiredFieldValidator>

  <br />

  <asp:Label ID="lblmsg" runat="server"></asp:Label>

  <br />

  <br />

        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />

  <asp:Button ID="btnClear" runat="server" Text="Clear" OnClick="btnClear_Click" />

        </td>

</tr>


12345678_0001
浏览 597回答 3
3回答
随时随地看视频慕课网APP
我要回答