cadi2108
cadi2108

Reputation: 1280

datepicker validation

I have two inputs fields of date:

<input type='text' id='txtLeaveDate' name='txtLeaveDate' class='date'  /> 
<input type='text' id='txtArriveDate' name='txtArriveDate' class='date' /> 

validation script:

$().ready(function() {
// validate the comment form when it is submitted

// validate signup form on keyup and submit
$('#ticketform').validate({
    rules: {
        txtLeaveDate: 'required',
                    txtArriveDate: 'required'

    },
    messages: {
        txtLeaveDate: 'Required!',
        txtArriveDate: 'Required!'

    }
});
});
</script>   

and datepicker script:

    $('.date').datepicker({
        dateFormat:'dd.mm.yy',
        onClose: function () {
            $('.date').valid();
        }

    });

But always I have error messages: 'Required'.

Additionaly, I want to do that #txtArriveDate mustn't be earlier than #txtLeaveDate, but I don't know is it possible.

Upvotes: 1

Views: 3580

Answers (3)

cadi2108
cadi2108

Reputation: 1280

Because my input had class='date', it was validated and was wrong. I had one message Required! for all of the problems. That was reason.

To second part I uset this tutorial: http://jquerybyexample.blogspot.com/2012/01/end-date-should-not-be-greater-than.html

Upvotes: 1

Zahid Riaz
Zahid Riaz

Reputation: 2889

have a look on this jQuery Datepicker validation There are so many types of validation avaialble in this file. Do as you want

Upvotes: 1

Tarun Gupta
Tarun Gupta

Reputation: 1242

Please check your jquery jar, It may be due conflict ion between the jar. Because same problem i have faced and found the conflict ion between the jquery jars.

Upvotes: -1

Related Questions