Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if the user enters a date in a textbox I want to validate both :

1. that date is in MM-DD-yyyy format

2. Enter date is is less than from current date.

using one validator can i achive this if any one suggest me.

i am already using Regular expression for mm/dd/yyyy format and java script function for birth date is less than from current date, but how can i achive this using only one validator if know suggest me because i got two different validation message.
Posted
Updated 29-Sep-11 2:11am
v3
Comments
sravani.v 29-Sep-11 8:07am    
If u want I will provide code in javascript

Hi,

I developed some code for your requirement

try this

JavaScript
<script language ="javascript" >
    function delval() {
        var num = document.getElementById("txtdate").value;
        var pattern = /(^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]$)/;
        if (num.search(pattern) == -1)
            alert("Invalid");
        else {
            var pd = new Date();
            var bd = new Date();
            var df = num.split('-');
            bd.setFullYear(df[2], df[0], df[1]);
            if (bd < pd) {
                alert("Valid");
            }
            else {
                alert("DOB is lessthan Today");
            }
        }

    }

</script>


I hope this is work for you too

All the Best
 
Share this answer
 
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900