loyalflow
loyalflow

Reputation: 14879

How to use Globalize.js to change the date format that validation uses?

I have the globalize.js file, and I want to force the dateformat to dd/mm/yyyy at a global level somewhere so then all jquery validation and datepicker etc. will pickup this dateformat.

Is this possible?

Upvotes: 0

Views: 6489

Answers (1)

Seany84
Seany84

Reputation: 5596

I believe the following applied in your layout would suffice:

<script type="text/javascript">
    $(function () {
        $.validator.methods.date = function (value, element) {
            return this.optional(element) || Globalize.parseDate(value, "dd/MM/yyyy") !== null;
        }
    });
</script>

Upvotes: 2

Related Questions