Merge lp:~canonical-website-editors/resource-centre/bug-1660616 into lp:resource-centre

Proposed by Graham Bancroft
Status: Merged
Merged at revision: 96
Proposed branch: lp:~canonical-website-editors/resource-centre/bug-1660616
Merge into: lp:resource-centre
Diff against target: 96 lines (+19/-36)
1 file modified
includes/_digest.php (+19/-36)
To merge this branch: bzr merge lp:~canonical-website-editors/resource-centre/bug-1660616
Reviewer Review Type Date Requested Status
Anthony Dillon Approve
Review via email: mp+322045@code.launchpad.net

Description of the change

## Done

Fix bug 1660616 - insights percuto newsletter form has no javascript check for required fields

## QA

Pop to http://insights.canonicalwebteam.com/ and hit submit on the 'Sign up for email updates' form, you should get a 'This field is required.' message, this doesn't happen on live. If you add a space to the field on live, you can submit the form, this isn't possible on canonicalwebteam.

To post a comment you must log in.
Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Code and QA +1

review: Approve
96. By Graham Bancroft

Remove phone and tablet from newsletter sign up

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'includes/_digest.php'
2--- includes/_digest.php 2016-11-29 09:10:46 +0000
3+++ includes/_digest.php 2017-04-06 07:30:24 +0000
4@@ -1,36 +1,18 @@
5 <div class="four-col box box-highlight box-digest">
6- <script>
7- function fieldValidate(field) {
8- /* call Mkto.setError(field, message) and return false to mark a field value invalid */
9- /* return 'skip' to bypass the built-in validations */
10- return true;
11- }
12- function getRequiredFieldMessage(domElement, label) {
13- return "This field is required";
14- }
15- function getTelephoneInvalidMessage(domElement, label) {
16- return "Please enter a valid telephone number";
17- }
18- function getEmailInvalidMessage(domElement, label) {
19- return "Please enter a valid email address";
20- }
21- </script>
22
23- <form class='mktoForm mktoNoJS' action='https://pages.canonical.com/index.php/leadCapture/save' method='post'>
24- <h2>Sign up for email updates</h2>
25- <p>Choose the topics you're interested in</p>
26+<form action="https://pages.canonical.com/index.php/leadCapture/save" method="post" id="mktoForm_1212">
27+ <h2>Sign up for email updates</h2>
28+ <p>Choose the topics you're interested in</p>
29 <?php
30 $term_list = wp_get_post_terms($post->ID, 'group', array("fields" => "slugs"));
31 $termsString = $term_list;
32 $current_tax = basename(get_permalink());
33 $cs = 'cloud-and-server';
34 $desktop = 'desktop';
35- $pt = 'phone-and-tablet';
36 $iot = 'internet-of-things';
37 ?>
38
39-
40- <ul class='mktoFormRow clearfix'>
41+ <ul class="no-bullets">
42 <li>
43 <ul class="no-bullets">
44 <li>
45@@ -42,28 +24,21 @@
46 <label for="insightsdesktop">Desktop</label>
47 </li>
48 <li>
49- <input class="mktoLogicalField mktoCheckboxList mktoHasWidth" type="checkbox" id="insightsphonetablet" name="insightsphonetablet" value="yes"<?php if(in_array($pt, $termsString) or $current_tax == $pt or is_home() or is_page_template( 'page-press.php' )) echo ' checked="checked" ' ?>/>
50- <label for="insightsphonetablet">Phone and tablet</label>
51- </li>
52- <li>
53 <input class="mktoLogicalField mktoCheckboxList mktoHasWidth" type="checkbox" id="insightsiot" name="insightsiot" value="yes"<?php if(in_array('internet-of-things', $termsString) or $current_tax == 'internet-of-things' or is_home() or is_page_template( 'page-press.php' )) echo ' checked="checked" ' ?>/>
54 <label for="insightsiot">Internet of Things</label>
55 </li>
56 </ul>
57 </li>
58- <li class='mktoFormCol'>
59- <label class="off-left mktoLabel" for='Email'>Your email</label>
60- <input type="text" placeholder="Your email" class='mktoField mktoTextField' name='Email' id='Email' required>
61+ <li class="mktFormReq mktField">
62+ <label for="Email" class="mktoLabel">Work email: <span>*</span></label>
63+ <input required id="Email" name="Email" maxlength="255" type="email" class="mktoField mktoEmailField mktoRequired" >
64 </li>
65-
66 <li class="mktField mktLblRight">
67 <span class="mktInput mktLblRight"><input class="mktFormCheckbox" name="canonicalUpdatesOptIn" id="canonicalUpdatesOptIn" value="yes" tabindex="9" type="checkbox" /><label>I would like to receive occasional updates from Canonical by email.</label>&nbsp;<span class="mktFormMsg"></span></span>
68 </li>
69-
70- <li>
71- <span style="display:none;"><input type="text" name="_marketo_comments" value=""></span>
72+ <li class="mktField">
73 <span class='mktoButtonWrap'><button type='submit' class='mktoButton'>Subscribe now</button></span>
74-
75+
76 <input value="1959" class="mktoField mktoFieldDescriptor" name="lpId" type="hidden">
77 <input value="30" class="mktoField mktoFieldDescriptor" name="subId" type="hidden">
78 <input type="hidden" name="lpurl" value="https://pages.canonical.com/Insights-Subscription_Insights-Subscription-test.html?cr={creative}&amp;kw={keyword}" />
79@@ -77,7 +52,15 @@
80 <input type="hidden" name="_mkt_trk" value=""/>
81 </li>
82 </ul>
83- </form>
84+</form>
85 </div>
86
87-<script language="JavaScript" src="https://app.marketo.com/js/public/jquery-latest.min.js" type="text/javascript"></script>
88+<script src="https://assets.ubuntu.com/v1/5d7e5bbf-jquery-2.2.0.min.js"></script>
89+<script src="https://assets.ubuntu.com/v1/d55f58bb-jquery.validate.js"></script>
90+
91+<script>
92+$("#mktoForm_1212").validate({
93+ errorElement: "span",
94+ errorClass: "mktFormMsg mktError"
95+});
96+</script>

Subscribers

People subscribed via source and target branches

to all changes: