如何检查文本框值是否为日期格式 [英] how to check the text box value is in date format or not
本文介绍了如何检查文本框值是否为日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上我是用于我的文本框,我正在使用ajax日历,因此文本框中的文本是我想要查找的文本或日期。如果它是文本意味着我想显示弹出窗口。是否有可能
首先我想知道如何给出条件
但现在我正在使用这个条件
Actually i am for my text box i am implimenting the ajax calender so the text in the text box is text or date i want find. if it is text means i want to display popup. is it possible
first i want to know how to give the condition
But now i am using this condition
if ( txtAppDate.Text.ToString() == "")
{
string radalertscript1 = "<script language='javascript'>function f(){alert('Please select the Appointment Date ', 330, 210,'My Title'); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript1);
return;
}
推荐答案
使用RegularExpressionValidator并捕获isValid属性(如果有效则为日期,如果无效则为文本) 。
use RegularExpressionValidator and capture the isValid property if it is valid then it is date if Invalid then it is text.
在JavaScript或.NET中,最好只是尝试将字符串解析为日期/时间并查看它是否失败。
-SA
In both JavaScript or .NET, it's the best to just try to parse string into date/time and see if it fails or not.
—SA
这篇关于如何检查文本框值是否为日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文