asp.net中的验证控件 [英] validation control in asp.net

查看:74
本文介绍了asp.net中的验证控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以格式mm.dd.yyyy

asp.net验证asp.net中文本框中的日期,如果要验证textBox,请尝试此操作



 bool isValid = true;
        尝试
        {
            字符串dt = TextBox1.Text;
            DateTime dateTime = DateTime.ParseExact(dt,"MM.dd.yy",System.Globalization.CultureInfo.InvariantCulture);
        }
        抓住
        {
            this.Response.Write(输入的无效日期 br  > );
            isValid = false;
        }
        this.Response.Write("isValid:" + isValid +" br  


验证日期在所有情况下均无法正常工作.
最好使用提到的格式的ajax日历扩展器...
希望对您有帮助


how to validate date in a textbox in asp.net in format mm.dd.yyyy

解决方案

try this if you want to validate textBox

bool isValid = true;
        try
        {
            string dt = TextBox1.Text;
            DateTime dateTime = DateTime.ParseExact(dt, "MM.dd.yy", System.Globalization.CultureInfo.InvariantCulture);
        }
        catch
        {
            this.Response.Write("Invalid Date entered<br>");
            isValid = false;
        }
        this.Response.Write("isValid: " + isValid + "<br>");


validating the date is will not work properly in all the situations .
its better to use ajax calender extender in that mention the format ...
hope it helps you


这篇关于asp.net中的验证控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆