2014-04-16 01:48:10 +02:00
|
|
|
(function($) {
|
|
|
|
$(document).ready(function() {
|
2014-07-25 04:52:56 +02:00
|
|
|
var messages = {<% loop $Fields %><% if $ErrorMessage && not $SetsOwnError %><% if ClassName == EditableCheckboxGroupField %>
|
2014-08-07 01:31:18 +02:00
|
|
|
'{$Name.JS}[]': '{$ErrorMessage.JS}'<% if not Last %>,<% end_if %><% else %>
|
|
|
|
'{$Name.JS}': '{$ErrorMessage.JS}'<% if not Last %>,<% end_if %><% end_if %><% end_if %><% end_loop %>
|
2014-07-25 04:52:56 +02:00
|
|
|
};
|
|
|
|
|
2014-08-11 01:09:31 +02:00
|
|
|
$(document).on("click", "input.text[data-showcalendar]", function() {
|
|
|
|
$(this).ssDatepicker();
|
|
|
|
|
|
|
|
if($(this).data('datepicker')) {
|
|
|
|
$(this).datepicker('show');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-04-16 01:48:10 +02:00
|
|
|
$("#Form_Form").validate({
|
|
|
|
ignore: ':hidden',
|
|
|
|
errorClass: "required",
|
|
|
|
errorElement: "span",
|
|
|
|
errorPlacement: function(error, element) {
|
2014-07-25 04:52:56 +02:00
|
|
|
error.addClass('message');
|
|
|
|
|
|
|
|
if(element.is(":radio") || element.parents(".checkboxset").length > 0) {
|
2014-04-16 01:48:10 +02:00
|
|
|
error.insertAfter(element.closest("ul"));
|
|
|
|
} else {
|
|
|
|
error.insertAfter(element);
|
|
|
|
}
|
|
|
|
},
|
2014-07-25 04:52:56 +02:00
|
|
|
messages: messages,
|
2014-04-16 01:48:10 +02:00
|
|
|
rules: {
|
|
|
|
<% loop $Fields %>
|
2014-07-25 04:52:56 +02:00
|
|
|
<% if $Validation %><% if ClassName == EditableCheckboxGroupField %>
|
|
|
|
'{$Name.JS}[]': {$ValidationJSON.RAW}
|
|
|
|
<% else %>
|
2014-04-16 01:48:10 +02:00
|
|
|
'{$Name.JS}': {$ValidationJSON.RAW},
|
2014-07-25 04:52:56 +02:00
|
|
|
<% end_if %><% end_if %>
|
2014-04-16 01:48:10 +02:00
|
|
|
<% end_loop %>
|
|
|
|
},
|
|
|
|
<% if $EnableLiveValidation %>
|
|
|
|
// Enable live validation
|
|
|
|
onfocusout : function(element) { this.element(element); }
|
|
|
|
<% end_if %>
|
|
|
|
});
|
|
|
|
<% if $HideFieldLabels %>
|
|
|
|
// Hide field labels (use HTML5 placeholder instead)
|
|
|
|
$("#Form_Form label.left").each(function() {
|
|
|
|
$("#"+$(this).attr("for"))
|
|
|
|
.attr("placeholder", $(this).text());
|
|
|
|
$(this).remove();
|
|
|
|
});
|
|
|
|
Placeholders.init();
|
|
|
|
<% end_if %>
|
|
|
|
});
|
|
|
|
})(jQuery);
|