日期:2014-05-17 浏览次数:20935 次
一 Asp.Net实现多行文本,正则表达式验证
<asp:TextBox ID="txtDescription" runat="server" Height="82px" MaxLength="500" TextMode="MultiLine"
????????????????????? Width="501px"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator3"
????????????????????????? runat="server" ErrorMessage="*请输入定义与描述" ControlToValidate="txtDescription" Display="Dynamic"></asp:RequiredFieldValidator>
????????????????? <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtDescription"
????????????????????? Display="Dynamic" ErrorMessage="*定义与描述长度不能大于500个字符" ValidationExpression="^(\s|\S){0,500}$"></asp:RegularExpressionValidator></label>
二 禁用页面中的回车键
<script language="javascript" type="text/javascript">
// 禁用页面中的回车键
function form_onkeydown(){
//alert(window.event.srcElement.tagName);
??? if(event.keyCode == 13)
??? {?????
??????? event.returnValue=false;
??? }
}
document.onkeydown=form_onkeydown;
</script>
三 解决禁用页面回车键后多行文本无法换行问题
<script language="javascript" type="text/javascript">
// 禁用页面中的回车键
function form_onkeydown(){
//alert(window.event.srcElement.tagName);
??? if(event.keyCode == 13&&window.event.srcElement.tagName!="TEXTAREA")
??? {?????
??????? event.returnValue=false;
??? }
}
</script>
<body onkeydown="form_onkeydown();" >
</body>