1 function _(s) { return s; } // dummy function for gettext
3 // http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855
4 String.prototype.format = function() { return formatstr(this, arguments); };
5 function formatstr(str, col) {
6 col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1);
8 return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) {
9 if (m == "%%") { return "%"; }
10 if (m == "%s") { return col[idx++]; }
15 jQuery.validator.addMethod( "category_code_check", function(value,element){
16 var patt = /^[A-Za-z0-9]{0,10}$/g;
17 if (patt.test(element.value)) {
22 }, MSG_LETTERS_NUMBERS_ONLY
25 jQuery.validator.addMethod( "enrollment_period", function(){
26 enrolmentperiod = $("#enrolmentperiod").val();
27 enrolmentperioddate = $("#enrolmentperioddate").val();
28 if (( $("#enrolmentperiod").val() === "" && $("#enrolmentperioddate").val() === "") || ($("#enrolmentperiod").val() !== "" && $("#enrolmentperioddate").val() !== "")) {
33 }, MSG_ONLY_ONE_ENROLLMENTPERIOD
36 jQuery.validator.addMethod( "password_match", function(value,element){
37 var MSG_PASSWORD_MISMATCH = ( MSG_PASSWORD_MISMATCH );
38 var password = document.getElementById('password').value;
39 var confirmpassword = document.getElementById('password2').value;
41 if ( password != confirmpassword ){
47 }, MSG_PASSWORD_MISMATCH
51 var x=f.value.toUpperCase();
56 $(document).ready(function() {
57 if ($("#branches option:selected").length < 1) {
58 $("#branches option:first").attr("selected", "selected");
60 $("#categorycode").on("blur",function(){
64 $("#enrolmentperioddate").datepicker({
66 }); // Require that "until date" be in the future
68 $("#category_form").validate({
72 category_code_check: true
78 required: function(element){
79 return $("#enrolmentperioddate").val() === "";
82 enrollment_period: true,
84 enrolmentperioddate: {
85 required: function(element){
86 return $("#enrolmentperiod").val() === "";
88 enrollment_period: true,
89 // is_valid_date ($(#"enrolementperioddate").val());
91 dateofbirthrequired: {
109 required: MSG_ONE_ENROLLMENTPERIOD
111 enrolmentperioddate: {
112 required: MSG_ONE_ENROLLMENTPERIOD
117 $("#createpatron").validate({
130 password_strong: true,
131 password_no_spaces: true
140 required: MSG_PASSWORD_MISMATCH
146 $("#createitemform").validate();
147 $("#createcirculationrule").validate();