LukeS Posted November 26, 2017 Share Posted November 26, 2017 Hi there, I want to make the mobile phone number a mandatory field for customers when setting up their profile (having re-badged it as emergency contact number - I’m using CubeCart as a booking system for sailing where everyone who books need to provide us with emergency contact details of someone ashore). I have added the “required” statement to the mobile input statement in templates.content.profile.php of the Standard foundation template (copied from the existing required input fields) - and mirrored the wording at the end of the file for validation checks as well as adding error wording in the languages definitions - but it’s not working. Clearly I’m missing something more fundamental - like some code somewhere that does the validation? Any help VERY gratefully received. Luke Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 26, 2017 Share Posted November 26, 2017 (edited) One thing to keep in mind is that the web browser caches page resource files: CSS, javascript, images. So, your browser may be using the older cached copy of the javascript validation file. Often, using the keyboard shortcut CTRL-F5 will force the browser to fetch fresh copies of page resource files. CubeCart also has an internal cache of compiled template files. You may need to have CubeCart dump that cache. In admin, Maintenance, Rebuild tab, check Clear cache. Edited November 26, 2017 by bsmither Quote Link to comment Share on other sites More sharing options...
LukeS Posted November 27, 2017 Author Share Posted November 27, 2017 Hello again (you helped me out a couple of weeks back). I've tried clearing caches at both ends but it still doesn't seem to be working. Below is the before and after versions of the code (with the format of the "required" elements copied from one of the existing required fields). The placeholder language seems to be working fine - just not the "required" function. BEFORE <div class="row"> <div class="small-12 large-8 columns"><label for="acc_mobile" class="show-for-medium-up">{$LANG.address.mobile}</label><input type="text" name="mobile" id="acc_mobile" value="{$USER.mobile}" placeholder="{$LANG.address.mobile}"></div> AFTER <div class="row"> <div class="small-12 large-8 columns"><label for="acc_mobile" class="show-for-medium-up">{$LANG.address.mobile}</label><input type="text" name="mobile" id="acc_mobile" class="required" value="{$USER.mobile}" placeholder="{$LANG.address.mobile} {$LANG.form.required}" required></div> At the end of the file I have <div class="hide" id="validate_mobile">{$LANG.account.error_valid_mobile_phone}</div> (although I confess I have no understanding of how this works?!) and in the language definitions I have <string name="error_valid_mobile_phone" introduced="5.0.0"><![CDATA[Please enter a valid mobile phone number.]]></string> Somewhere the programme must be making the connection between the fact that if I submit the form with a required field empty it needs to look up the error message in language definitions via the "error_valid_....." definition at the end of the profile file - and I assume that somewhere I need to update something else so that it will do a similar look up for mobile phone - I just don't know enough about PHP to be able to work out where/how. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 27, 2017 Share Posted November 27, 2017 I think you have most of what you need. I think the last piece of the puzzle is 3.cubecart.validate.js, changing the rules to match phone: in the various locations as desired. Again, changing this page resource will require you to force your browser to fetch a fresh copy. Quote Link to comment Share on other sites More sharing options...
LukeS Posted November 29, 2017 Author Share Posted November 29, 2017 Once again you have solved my problem - so once again many thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.