これは、テキストボックスにユーザーのクリックが、それは日付ピッカーを選択し、日付を開いたとき、私はテキストボックスを持っている私のコード上記のコードでJQueryを使用してasp.netのTextBoxに日付を入力するときの検証方法?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="datetime.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" />
<script type="text/javascript">
$(function() {
$("[id$=txtDate]").datepicker({});
$("#txtDate").blur(function() {
val = $(this).val();
val1 = Date.parse(val);
if (isNaN(val1) == true && val !== '') {
alert('Date is not valid');
$("#txtDate").val($.datepicker.formatDate("mm-dd-yy", new Date()));
}
else {
console.log(val1);
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
</form>
</body>
</html>
です。 jqueryを使用して検証する方法を手動で日付を入力する場合。 例: - 01011 - >この時間は、無効な日付 例:のアラートを示しています - 2016年1月1日
を使用してasp.netの日時のための最終的なコードであります入力された値は常に合法です。 – FDavidov