Hi All!
I'm a squiz noob just getting up to speed on how it all works in my new role. I just have a small issue in regards to validating forms using the JQuery Validation method "EqualTo".
It all works fine offline but I had to devise a workaround whereby the validation function would be able to compare IDs as opposed to names as the Squiz system generates them with a colon (i.e. q2811473:q3) which breaks my javascript.
But anyway, the form seems to be broke now. Can't even submit it. The purpose of the form is for subscribers to change their email address and the form sends the admin the users new details via system generated email. We just want to have a repeat email input field to ensure users don't make a mistake when submitting.
Is there a native SQUIZ way of achieving this as I am not convinced that this Jquery solution will work. My code below:
<!-- INSERT EXTERNAL JQUERY FILES USED FOR FORM VALIDATION --> <script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script> <script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script><script>
// avoids form submit
jQuery.validator.setDefaults({
debug: true,
success: “valid”
});var form = $(’#form_email_281473’),
email1 = ‘#’+form.find(’#q281473_q2’).attr(‘id’),
email2 = form.find(’#q281473_q3’).attr(‘name’);var r = {};
r[email2] = { equalTo: email1 };$( “#form_email_281473” ).validate({
rules: r,
“q281473:q2”: “required”,
});</script>
<div class=“slq-form preference-form” id=“preference-change-email-form”>
<style>
#preference-change-email-form .form-field-label { font-weight: bold; padding-right: 10px; }
#preference-change-email-form .form-field-label-note { font-weight: normal; }
/(input { border: 1px solid blue; }/
input.error { border: 1px solid red; }</style>
<H1>Change your preferred email address</H1>
<P>Use this form to change your email address registered on our database.</P>
<P>Fields marked with a <SPAN class=“form-field-required”>*</SPAN>red asterisk are Required.</P>
<DIV class=“form-error-messages”>%form_errors_message% %form_errors%</DIV>
<div id=“preference-change-email-form-fields”>
<DIV class="form-field-label">Current subscribed email <abbr class="sq-form-required-field" title="required">*</abbr>:</DIV> <DIV class="form-field-box"> <!-- Current email address --> %globals_get_cse% <div style="display:none;"><input type="hidden" name="q281473:q1" value="%globals_get_cse%" size="40" maxlength="150" id="q281473_q1" tabindex="1" class="sq-form-field" /></div> </div> <DIV class="form-field-divider"></DIV> <!-- DESIRED NEW EMAIL ADDRESS --> <DIV class="form-field-label">Desired new email address: <abbr class="sq-form-required-field" title="required">*</abbr></DIV> <DIV class="form-field-box">%question_field_281473_q2%</DIV> <p id="error_q281473_q2" class="sq-form-error">%question_error_281473_q2%</p> <DIV class="form-field-divider"></DIV>
<DIV class=“form-field-divider”></DIV>
<!-- CONFIRM DESIRED NEW EMAIL ADDRESS --> <DIV class="form-field-label">Confirm new email address: <abbr class="sq-form-required-field" title="required">*</abbr></DIV> <DIV class="form-field-box">%question_field_281473_q3%</DIV> <p id="error_q281473_q3" class="sq-form-error">%question_error_281473_q3%</p> <DIV class="form-field-divider"></DIV> <!-- Subscriber ID --> <INPUT id="q281473_q4" value="%globals_get_reid%" type="hidden" maxLength="50" name="q281473:q4"> <p id="error_q281473_q4" class="sq-form-error">%question_error_281473_q4%</p> <!-- SECURITY KEY --> <DIV class="form-field-label">Security key<SPAN class="form-field-required">*</SPAN><BR> <DIV class="form-field-label-note form-field-label-note-indent">Please enter the letters from the large box here into the small box below it. This helps us prevent spamming.</DIV> </DIV> <DIV class="form-field-box">%form_captcha_image%<BR>%form_captcha_field%<BR>%form_captcha_link% </DIV> <p class="sq-form-error">%form_captcha_errors%</p> <DIV class="form-field-divider"></DIV> <DIV class="form-field-box"><span class="form-field-button-submit">%submit_button%</span><span class="form-field-button-reset" style="MARGIN-LEFT: 25px">%reset_button%</span></DIV> <DIV class="form-field-divider"></DIV>
</div> <!-- /#preference-change-email-form-fields -->
<P> </P>
</div>