|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <title>Plugin Validate Contact Information</title> |
| 5 | + <link rel="stylesheet" href="../examples/styles.css" /> |
| 6 | + </head> |
| 7 | + |
| 8 | + <body> |
| 9 | + <small> <a href="/">All Plugins</a> > Accept Terms</small> |
| 10 | + <h1>Validate Contact Information</h1> |
| 11 | + <p> |
| 12 | + This plugin adds a <i>Validate Contact Information</i> validator to to Shopify's contact information checkout |
| 13 | + page. |
| 14 | + </p> |
| 15 | + <div class="plugin-preview"> |
| 16 | + <h2>Contact information</h2> |
| 17 | + ... |
| 18 | + <h2>Shipping address</h2> |
| 19 | + <div data-buyer-accepts-marketing> |
| 20 | + <div class="fieldset-description"> |
| 21 | + <div class="section__content"> |
| 22 | + <input type="text" placeholder="Street" id="checkout_shipping_address_address1" /> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + ... |
| 27 | + <div align="right"><button align="right" type="submit">Continue to shipping method</button></div> |
| 28 | + </div> |
| 29 | + |
| 30 | + <script> |
| 31 | + window.Shopify = { |
| 32 | + Checkout: { |
| 33 | + step: 'contact_information' |
| 34 | + } |
| 35 | + }; |
| 36 | + </script> |
| 37 | + <script> |
| 38 | + fetch('shopify-plugin-loader.min.js').then(function(result) { |
| 39 | + result.text().then(function(script) { |
| 40 | + const plugin = document.createElement('script'); |
| 41 | + plugin.innerHTML = script; |
| 42 | + document.body.appendChild(plugin); |
| 43 | + window.ShopifyPlugins.checkout.contactInformation.load('validate-contact-information', [ |
| 44 | + { |
| 45 | + selector: '#checkout_shipping_address_address1', |
| 46 | + pattern: /.*[a-z]+.*[0-9]+.*/i, |
| 47 | + errorMessage: 'Please enter streetname AND number' |
| 48 | + } |
| 49 | + ]); |
| 50 | + }); |
| 51 | + }); |
| 52 | + </script> |
| 53 | + </body> |
| 54 | +</html> |
0 commit comments