Bugzilla – Attachment 41469 Details for
Bug 14620
Contact information validations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14620 - Whitespace fix for validations
Bug-14620---Whitespace-fix-for-validations.patch (text/plain), 7.94 KB, created by
Lari Taskula
on 2015-08-13 11:44:08 UTC
(
hide
)
Description:
Bug 14620 - Whitespace fix for validations
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2015-08-13 11:44:08 UTC
Size:
7.94 KB
patch
obsolete
>From 6238c10e82449192ac8a4a81090503a01fdfb3fb Mon Sep 17 00:00:00 2001 >From: Lari Taskula <larit@student.uef.fi> >Date: Thu, 13 Aug 2015 14:38:53 +0300 >Subject: [PATCH] Bug 14620 - Whitespace fix for validations > >This fix trims emails and phone numbers just before form is sent. >--- > Koha/Validation.pm | 6 ++-- > .../prog/en/modules/members/memberentrygen.tt | 32 ++++++++++++++++++---- > .../bootstrap/en/modules/opac-memberentry.tt | 16 +++++++++++ > .../bootstrap/en/modules/opac-messaging.tt | 9 ++++++ > 4 files changed, 54 insertions(+), 9 deletions(-) > >diff --git a/Koha/Validation.pm b/Koha/Validation.pm >index 90f1ef0..e952319 100644 >--- a/Koha/Validation.pm >+++ b/Koha/Validation.pm >@@ -53,6 +53,7 @@ sub validate_email { > > # make sure we are allowed to validate emails > return 1 if not C4::Context->preference("ValidateEmailAddress"); >+ return 0 if $address =~ /(^(\s))|((\s)$)/; > return 0 if not defined $address; > return (not defined Email::Valid->address($address)) ? 0:1; > } >@@ -70,15 +71,12 @@ returns: 1 if the given phone number is valid, 0 otherwise. > sub validate_phonenumber { > my $phonenumber = shift; > >- $phonenumber =~ s/\s+//g; >- > # make sure we are allowed to validate phone numbers > return 1 if C4::Context->preference("ValidatePhoneNumber") eq "OFF"; > return 1 if $phonenumber eq ""; > return 0 if not defined $phonenumber; > > my $regex = get_phonenumber_regex(C4::Context->preference("ValidatePhoneNumber")); >- #die $regex; > return ($phonenumber !~ /$regex/) ? 0:1; > } > >@@ -100,7 +98,7 @@ sub get_phonenumber_regex { > return qr/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/; > } > elsif (C4::Context->preference("ValidatePhoneNumber") eq "fin") { >- 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}$/; >+ 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$/; > } > > return ""; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 8f4a251..d0a44d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -37,7 +37,6 @@ > > var MSG_INCORRECT_PHONE = _("Please enter a valid phone number."); > $.validator.addMethod('phone', function(value) { >- value = value.trim(); > if (!value.trim()) { > return 1; > } >@@ -82,9 +81,20 @@ > $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting'); > if (form.beenSubmitted) > return false; >- else >- form.beenSubmitted = true; >- form.submit(); >+ else { >+ form.beenSubmitted = true; >+ [% IF ValidateEmailAddress %] >+ $("#email, #emailpro, #B_email").each(function(){ >+ $(this).val($.trim($(this).val())); >+ }); >+ [% END %] >+ [% IF ValidatePhoneNumber %] >+ $("#phone, #phonepro, #B_phone, #SMSnumber").each(function(){ >+ $(this).val($.trim($(this).val())); >+ }); >+ [% END %] >+ form.submit(); >+ } > } > }); > >@@ -95,6 +105,10 @@ > $("#email").on("input", function(){ > disableCheckboxesWithInvalidPreferences($(this), "email"); > }); >+ $("#email, #emailpro, #B_email").on("change, click", function(){ >+ $(this).val($.trim($(this).val())); >+ disableCheckboxesWithInvalidPreferences($(this), "email"); >+ }); > [% END %] > > [% IF ValidatePhoneNumber %] >@@ -105,11 +119,19 @@ > disableCheckboxesWithInvalidPreferences($("#phone"), "phone"); > [% END %] > $("#SMSnumber").on("input", function(){ >- disableCheckboxesWithInvalidPreferences($(this), "sms"); >+ disableCheckboxesWithInvalidPreferences($(this), "sms"); >+ }); >+ $("#SMSnumber").on("change, click", function(){ >+ $(this).val($.trim($(this).val())); >+ disableCheckboxesWithInvalidPreferences($(this), "sms"); > }); > $("#phone").on("input", function(){ > disableCheckboxesWithInvalidPreferences($(this), "phone"); > }); >+ $("#phone, #phonepro, #B_phone").on("change, click", function(){ >+ $(this).val($.trim($(this).val())); >+ disableCheckboxesWithInvalidPreferences($(this), "phone"); >+ }); > [% END %] > > var mrform = $("#manual_restriction_form"); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index d08f9d2..744eb7f 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -870,6 +870,16 @@ > } > else { > form.beenSubmitted = true; >+ [% IF ValidateEmailAddress %] >+ $("#borrower_email, #borrower_emailpro, #borrower_B_email").each(function(){ >+ $(this).val($.trim($(this).val())); >+ }); >+ [% END %] >+ [% IF ValidatePhoneNumber %] >+ $("#borrower_phone, #borrower_phonepro, #borrower_B_phone, #SMSnumber").each(function(){ >+ $(this).val($.trim($(this).val())); >+ }); >+ [% END %] > form.submit(); > } > }, >@@ -883,6 +893,12 @@ > error.css('width', 'auto'); > } > }); >+ $("#borrower_email, #borrower_emailpro, #borrower_B_email").on("change, click", function(){ >+ $(this).val($.trim($(this).val())); >+ }); >+ $("#borrower_phone, #borrower_phonepro, #borrower_B_phone").on("change, click", function(){ >+ $(this).val($.trim($(this).val())); >+ }); > }); > //]]> > </script> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >index 9743f5a..cfbff65 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >@@ -182,6 +182,11 @@ > } > else { > form.beenSubmitted = true; >+ [% IF ValidatePhoneNumber %] >+ $("#SMSnumber").each(function(){ >+ $(this).val($.trim($(this).val())); >+ }); >+ [% END %] > form.submit(); > } > }, >@@ -212,6 +217,10 @@ > $("#SMSnumber").on("input", function(){ > disableCheckboxesWithInvalidPreferences($(this), "sms"); > }); >+ $("#SMSnumber").on("change, click", function(){ >+ $(this).val($.trim($(this).val())); >+ disableCheckboxesWithInvalidPreferences($(this), "sms"); >+ }); > [% END %] > }); > //]]> >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14620
:
41461
|
41469
|
41470
|
41471
|
41472
|
41502
|
41527
|
42080
|
42107
|
42456
|
42462
|
44703
|
44705
|
61843
|
67812
|
67813
|
93930
|
93931