latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Javascript Validation Error – Pro Forms

Home Forums Community Forum Javascript Validation Error – Pro Forms

This topic contains 5 replies, has 2 voices. Last updated by  Bruce 4 years, 4 months ago.

Topic Author Topic
Posted: Wednesday Sep 5th, 2012 at 9:37 pm #24242

Hi,

I am having problems with the checkout form when $_POST variable is being set as the value passed by a different page.

When debugging it, I found out that you need to type something first to the form before the javascript activates.
When I retyped every required field. The alert box did not appear anymore.

So, I think the quickest solution for this is turn off javascript validation in one of the form pages. But I cannot locate where I can do this. Can you help me?

Error Route:


Join Now Page -> Checkout page

Join now page passes post data to the checkout page. (i.e. Zip Code, Country, First Name, Last Name and etc.)
When completing the form after the user enters their credit card information. A Javascript alert box appears without any distinction on what input box has a missing value. Hence, the input boxes already have value but generated via $_POST var.

After re-input of values to the input boxes, that time the javascript did not appear and it went ok.


Success Route:


Checkout Page

When accessing Checkout Page directly then inputting data. It goes well without any javascript alert boxes.


PS: If needed, I will gladly give the links to the two pages.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Thursday Sep 6th, 2012 at 1:42 am #24259
Bruce
Username: Bruce
Staff Member

Hi Randy,

It does sound like the way you’re modifying your forms would require you to turn off this validation, however that could lead to some errors being thrown. However, if you’re willing to create another way of validation I believe you’ll need to edit the file that creates the Pro Forms itself to ‘turn off JavaScript validation’. You can find information on this within our FAQs.

Let me know if I can help you in any other way.

Posted: Thursday Sep 6th, 2012 at 8:50 pm #24422

Hi Bruce,

What I need is to modify only the validation behavior, I think a php file handles it. But I do not know which file.
Cristián advised to me before to modify the pro forms via mu-plugins folder, and so I did. But this is a different issue

I do not need to turn off the whole javascript or the javascript for the authorize.net. Please help me, I am doing this for my current employer. And I need to give them what they want.

what file handles this url?

s2member/s2member-o.php?ws_plugin__s2member_js_w_globals=1&qcABC=1&ver=120703-120703-1968823089

I tried to take a look at s2member-o.php but there was no lead to where ws_plugin__s2member_js_w_globals function is. I am assuming it is inside the pro forms folder.

If you need my employer’s account here at s2member I can login using that one. Then use that for replying.

Best Regards,

Posted: Thursday Sep 6th, 2012 at 9:13 pm #24428

Please take a look at this page,

https://www.seniorwealthclub.com/standard-package-benefits/ – when you sign up directly to this page all goes well.

https://www.seniorwealthclub.com/join-now/ – Please select standard checkout (Default value)

But when you pass a value to the checkout form, a javascript alert box pops up then it does not contain which input box is missing a value. Please take a look at Error Route: at my first reply.

The checkout form’s (standard package and special value package) behavior, I changed it to be a custom field. So that user’s can change their Address, Zip, etc. information.


Topics Involve to Project
http://www.s2member.com/forums/topic/authnet-pro-form-saving-address-fields/
http://www.s2member.com/forums/topic/authnet-pro-form-saving-address-fields/#post-14459 – Support Rep’s Reply
http://www.s2member.com/forums/topic/s2member-pro-authnet-checkout/


Test Credit Card
No. 4007000000027
Exp Date. 07/2015 (can be any month or year, as long as it is more than the current year)
cvv. 323 (any 3-4 digit)

Posted: Thursday Sep 6th, 2012 at 10:09 pm #24441

I think I solved it. Gonna give it another try.

EDIT:

It did not work, I tried using javascript to fill in values. But looks like the email and zip code needs to be filled in via keyboard interaction.

I just need to disable or change it to a different one instead of .keyup().

EDIT2:

I have found the problem.

add_action ("ws_plugin__s2member_pro_before_sc_authnet_form", "s2_customize_pro_form", 1000);
function s2_customize_pro_form ($vars = array())
    {
	/*  Don't pre populate when/if the Pro Form has just been POSTd, and/or if it's a Modification Form 
		with modify="1", because s2Member already pre populates Pro Forms in that scenario, with the 
		User's existing Email and Username. */
	if(empty ($_POST["s2member_pro_authnet_checkout"]) && empty($vars["attr"]["modify"])) {
?>
        <script type = "text/javascript">
		function getParameterByName(name)
		{
		  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
		  var regexS = "[\\?&]" + name + "=([^&#]*)";
		  var regex = new RegExp(regexS);
		  var results = regex.exec(window.location.href);
		  if(results == null)
		    return "";
		  else
		    return decodeURIComponent(results[1].replace(/\+/g, " "));
		}
		
            (function ($) /* Wraps this `$ = jQuery` routine. */
                {
                    $.fn.swapWith = function (to) /* Utility extension for jQuery. */
                        {
                            return this.each (function ()
                                {
                                    var $to = $ (to).clone (true), $from = $ (this).clone (true);
                                    $(to).replaceWith ($from), $ (this).replaceWith ($to);
                                });
                        };
                    /**/
                    $(document).ready (function () /* Handles email-to-username on keyup. */
                        {	
								
						/* Generate random number to append to username, 
                        hopefully making it unique (yes, this isn't perfect!) */
                        var randomNum = Math.ceil(Math.random()*999);

                        if($('input#s2member-pro-authnet-checkout-email').length) {
							var email = 'input#s2member-pro-authnet-checkout-email';
							var login = 'input#s2member-pro-authnet-checkout-username';
							$('#s2member-pro-authnet-checkout-form-username-div').hide();
						} else {
							var email = 'input#s2member-pro-authnet-registration-email';
							var login = 'input#s2member-pro-authnet-registration-username';
							$('#s2member-pro-authnet-registration-form-username-div').hide();
						}
						

                        /* Fill hidden username field with first part of email address
                            and append randomNum to hopefully make it unique. */
                        $ (email).keyup (function ()
                            {
                                $(login).val ($.trim ($ (email).val ().split (/@/)[0].replace (/[^\w]/gi, '')) + randomNum.toString());
                            });
                            $(login).val ($.trim ($ (email).val ().split (/@/)[0].replace (/[^\w]/gi, '')) + randomNum.toString());								
                        });
                        
                }) (jQuery);
        </script>
<?php
		}
    }

I have put $(login).val ($.trim ($ (email).val ().split (/@/)[0].replace (/[^\w]/gi, ”)) + randomNum.toString()); outside the hack provided before.

http://www.s2member.com/forums/topic/make-username-field-optional-and-hide-it/

I forgot I implemented this hack 1-3 months ago.

Thanks a lot! S2member

Posted: Thursday Sep 6th, 2012 at 11:19 pm #24452
Bruce
Username: Bruce
Staff Member

Hi Randy,

I’m going to take a look at this tonight and get back to you soon.

All of the JavaScript files for s2Member should be located within /s2member/includes/. I believe that the file you may be looking for is s2member-min.js which should be just a minimized version of s2member.js.

EDIT: Nevermind I see you have found the issue. Sorry I couldn’t have been more of a help. (lol)

Let us know if you have any more issues.

  • This reply was modified 4 years, 4 months ago by  Bruce.
Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.