View | Details | Raw Unified | Return to bug 14620
Collapse All | Expand All

(-)a/Koha/Validation.pm (-4 / +2 lines)
Lines 53-58 sub validate_email { Link Here
53
53
54
    # make sure we are allowed to validate emails
54
    # make sure we are allowed to validate emails
55
    return 1 if not C4::Context->preference("ValidateEmailAddress");
55
    return 1 if not C4::Context->preference("ValidateEmailAddress");
56
    return 0 if $address =~ /(^(\s))|((\s)$)/;
56
    return 0 if not defined $address;
57
    return 0 if not defined $address;
57
    return (not defined Email::Valid->address($address)) ? 0:1;
58
    return (not defined Email::Valid->address($address)) ? 0:1;
58
}
59
}
Lines 70-84 returns: 1 if the given phone number is valid, 0 otherwise. Link Here
70
sub validate_phonenumber {
71
sub validate_phonenumber {
71
    my $phonenumber = shift;
72
    my $phonenumber = shift;
72
73
73
    $phonenumber =~ s/\s+//g;
74
75
    # make sure we are allowed to validate phone numbers
74
    # make sure we are allowed to validate phone numbers
76
    return 1 if C4::Context->preference("ValidatePhoneNumber") eq "OFF";
75
    return 1 if C4::Context->preference("ValidatePhoneNumber") eq "OFF";
77
    return 1 if $phonenumber eq "";
76
    return 1 if $phonenumber eq "";
78
    return 0 if not defined $phonenumber;
77
    return 0 if not defined $phonenumber;
79
78
80
    my $regex = get_phonenumber_regex(C4::Context->preference("ValidatePhoneNumber"));
79
    my $regex = get_phonenumber_regex(C4::Context->preference("ValidatePhoneNumber"));
81
    #die $regex;
82
    return ($phonenumber !~ /$regex/) ? 0:1;
80
    return ($phonenumber !~ /$regex/) ? 0:1;
83
}
81
}
84
82
Lines 100-106 sub get_phonenumber_regex { Link Here
100
        return qr/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/;
98
        return qr/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/;
101
    }
99
    }
102
    elsif (C4::Context->preference("ValidatePhoneNumber") eq "fin") {
100
    elsif (C4::Context->preference("ValidatePhoneNumber") eq "fin") {
103
        return qr/^((90[0-9]{3})?0|\+358\s?)(?!(100|20(0|2(0|[2-3])|9[8-9])|300|600|700|708|75(00[0-3]|(1|2)\d{2}|30[0-2]|32[0-2]|75[0-2]|98[0-2])))(4|50|10[1-9]|20(1|2(1|[4-9])|[3-9])|29|30[1-9]|71|73|75(00[3-9]|30[3-9]|32[3-9]|53[3-9]|83[3-9])|2|3|5|6|8|9|1[3-9])\s?(\d\s?){4,20}$/;
101
        return qr/^((90[0-9]{3})?0|\+358\s?)(?!(100|20(0|2(0|[2-3])|9[8-9])|300|600|700|708|75(00[0-3]|(1|2)\d{2}|30[0-2]|32[0-2]|75[0-2]|98[0-2])))(4|50|10[1-9]|20(1|2(1|[4-9])|[3-9])|29|30[1-9]|71|73|75(00[3-9]|30[3-9]|32[3-9]|53[3-9]|83[3-9])|2|3|5|6|8|9|1[3-9])\s?(\d\s?){4,19}\d$/;
104
    }
102
    }
105
103
106
    return "";
104
    return "";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+23 lines)
Lines 84-93 Link Here
84
                    return false;
84
                    return false;
85
                else
85
                else
86
                    form.beenSubmitted = true;
86
                    form.beenSubmitted = true;
87
                    [% IF ValidateEmailAddress %]
88
                        $("#email, #emailpro, #B_email").each(function(){
89
                            $(this).val($.trim($(this).val()));
90
                        });
91
                    [% END %]
92
                    [% IF ValidatePhoneNumber %]
93
                        $("#phone, #phonepro, #B_phone, #SMSnumber").each(function(){
94
                            $(this).val($.trim($(this).val()));
95
                        });
96
                    [% END %]
87
                    form.submit();
97
                    form.submit();
88
                }
98
                }
89
        });
99
        });
90
100
101
        [% IF ValidateEmailAddress %]
102
        $("#email, #emailpro, #B_email").on("change click", function(){
103
            $(this).val($.trim($(this).val()));
104
        });
105
        [% END %]
106
        [% IF ValidatePhoneNumber %]
107
        $("#SMSnumber").on("change click", function(){
108
            $(this).val($.trim($(this).val()));
109
        });
110
        $("#phone, #phonepro, #B_phone").on("change click", function(){
111
            $(this).val($.trim($(this).val()));
112
        });
113
        [% END %]
91
        var mrform = $("#manual_restriction_form");
114
        var mrform = $("#manual_restriction_form");
92
        var mrlink = $("#add_manual_restriction");
115
        var mrlink = $("#add_manual_restriction");
93
        mrform.hide();
116
        mrform.hide();
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (+16 lines)
Lines 870-875 Link Here
870
                    }
870
                    }
871
                    else {
871
                    else {
872
                        form.beenSubmitted = true;
872
                        form.beenSubmitted = true;
873
                        [% IF ValidateEmailAddress %]
874
                        $("#borrower_email, #borrower_emailpro, #borrower_B_email").each(function(){
875
                            $(this).val($.trim($(this).val()));
876
                        });
877
                        [% END %]
878
                        [% IF ValidatePhoneNumber %]
879
                        $("#borrower_phone, #borrower_phonepro, #borrower_B_phone, #SMSnumber").each(function(){
880
                            $(this).val($.trim($(this).val()));
881
                        });
882
                        [% END %]
873
                        form.submit();
883
                        form.submit();
874
                    }
884
                    }
875
                },
885
                },
Lines 883-888 Link Here
883
                    error.css('width', 'auto');
893
                    error.css('width', 'auto');
884
                }
894
                }
885
            });
895
            });
896
            $("#borrower_email, #borrower_emailpro, #borrower_B_email").on("change click", function(){
897
                $(this).val($.trim($(this).val()));
898
            });
899
            $("#borrower_phone, #borrower_phonepro, #borrower_B_phone").on("change click", function(){
900
                $(this).val($.trim($(this).val()));
901
            });
886
        });
902
        });
887
    //]]>
903
    //]]>
888
    </script>
904
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt (-1 / +11 lines)
Lines 179-184 Link Here
179
            }
179
            }
180
            else {
180
            else {
181
                form.beenSubmitted = true;
181
                form.beenSubmitted = true;
182
                [% IF ValidatePhoneNumber %]
183
                    $("#SMSnumber").each(function(){
184
                        $(this).val($.trim($(this).val()));
185
                    });
186
                [% END %]
182
                form.submit();
187
                form.submit();
183
            }
188
            }
184
        },
189
        },
Lines 193-198 Link Here
193
        }
198
        }
194
    });
199
    });
195
200
201
    [% IF ( ValidatePhoneNumber ) %]
202
    $("#SMSnumber").on("change click", function(){
203
            $(this).val($.trim($(this).val()));
204
    });
205
    [% END %]
206
196
  });
207
  });
197
//]]>
208
//]]>
198
</script>
209
</script>
199
- 

Return to bug 14620