文本框的日期验证? [英] date validation for textbox?

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

问题描述

我尝试使用此代码...







I tried with this code...



function IsValidDateTime(Day, Mn, Yr) {
        var DateVal = Day + "/" + Mn + "/" + Yr;
        var dt = new Date(DateVal);

        if (dt.getDate() != Day) {
            alert('Invalid Date');
            return (false);
        }
        else if (dt.getMonth() != Mn) {
            //this is for the purpose JavaScript starts the month from 0
            alert('Invalid Date');
            return (false);
        }
        else if (dt.getFullYear() != Yr) {
            alert('Invalid Date');
            return (false);
        }


        return (true);
    }







这里工作正常...我的意思是它无法进入从键盘上的字符,但如果我删除数字..然后它显示一个exption意味着日期格式不正确..所以...我想从日历输入日期..但没有从键盘修改..请帮助我




Here it's working fine...i mean it cannot enter type of charaters from the keyboard,but if i delete the number.. then it shows an exption means date format is not correct..so...i want to enter date from calender..but no modifications from the key board..please help me

推荐答案

替代方法:探索 DatePicker [ ^ ]。这将为您做正确的验证。
Alternative approach: Explore the DatePicker[^]. This will do the right validations for you.


这篇关于文本框的日期验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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