【发布时间】:2015-05-23 17:03:20
【问题描述】:
我正在尝试使用 asp.net/bootstrap 制作验证表单。我正在用一个文本框对其进行测试。
目前这是我的代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script src="Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox runat="server" CssClass="form-control" ID="userNameTextBox" />
<input id="Submit1" type="submit" value="submit" />
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#form1').formValidation({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
<%=userNameTextBox.UniqueID%>: {
validators: {
notEmpty: {
message: 'The username is required and cannot be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9]+$/,
message: 'The username can only consist of alphabetical and number'
},
different: {
field: 'password',
message: 'The username and password cannot be the same as each other'
}
}
}
}
});
});
</script>
</body>
</html>
但是当我点击按钮时,什么也没有发生。我究竟做错了什么??谢谢你的帮助!
【问题讨论】:
-
我认为你可以像这样进行验证1000hz.github.io/bootstrap-validator
标签: jquery asp.net twitter-bootstrap