Link to home
Start Free TrialLog in
Avatar of searchsanjaysharma
searchsanjaysharma

asked on

How to compare two textboxes in jquery.

t1 and t2 are two be compared.
The type of values in t1 and t2 are dates.
t2 should be greater then t1
SOLUTION
Avatar of Atique Ansari
Atique Ansari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Mrunal
Mrunal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are also using jQuery ui, in particular datepicker, you can use $.datepicker.parseDate(format, string) to turn your date strings into a JavaScript Date object, which you can then compare using the standard < and >
Avatar of searchsanjaysharma
searchsanjaysharma

ASKER

<script type="text/javascript">
     $(document).ready(function () {
         $.validator.addMethod("txttdate", function (value, element) {
             var startDate = $('.txtfdate').val();
             return Date.parse(startDate) <= Date.parse(value) || value == "";
         }, "* End date must be after start date");
         $('#form1').validate();
     });
</script>

Not working