The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Captcha by BestWebSoft
[resolved] Validation not working in custom form (2 posts)

  1. crancherry
    Posted 2 years ago #

    I have a custom form. I have gotten the CAPTCHA to display, but no matter where I enter the CAPTCHA validation lines to the section of validation code, it breaks the validation for the form and also does not try to validate the CAPTCHA. I even had the developer of my theme try to place the lines and they could not figure it out. I have read all of the forum questions and see that anytime someone is asking this question, the answer is a copy-paste of the generic instructions. Can someone please assist with specific info about placing of the validation code?

    Here is the validation code from my form:

                    $subject_error_msg = get_option('contact_subject_error_message');
                    $name_error_msg = get_option('contact_name_error_message');
                    $email_error_msg = get_option('contact_email_error_message');
                    $message_error_msg = get_option('contact_message_error_message');
                    $mail_success_msg = get_option('contact_message_successful');
                    $mail_error_msg = get_option('contact_message_unsuccessful');
                    <!-- Validate script -->
                    <script type="text/javascript">
                        function validate_email(field,alerttxt)
                            with (field)
                                if (apos<1||dotpos-apos<2)
                                {$('#contact-error').empty().append(alerttxt);return false;}
                                else {return true;}
                        function check_field(field,alerttxt,checktext){
                            with (field)
                                var checkfalse = 0;
                                if(field.value == ""){
                                if(checkfalse==1){return false;}else{return true;}
                        function checkForm(thisform)
                            with (thisform)
                                var error = 0;
                                var message = document.getElementById('message');
                                if(check_field(message,"<?php echo $message_error_msg?>","")==false){
                                    error = 1;
                                var email = document.getElementById('email');
                                if (validate_email(email,"<?php echo $email_error_msg?>")==false)
                                {email.focus();error = 1;}
                                var contactname = document.getElementById('contactname');
                                if(check_field(contactname,"<?php echo $name_error_msg?>","")==false){
                                    error = 1;
                                if(error == 0){
                                    var contactname = document.getElementById('contactname').value;
                                    var email = document.getElementById('email').value;
                                    var message = document.getElementById('message').value;
                                    return true;
                                return false;
                    <!-- end of script -->


  2. bestwebsoft
    Plugin Author

    Posted 2 years ago #

    Hi crancherry,

    You have a script validation, i.e. you should you make it either in php or ajax-request by creating a function in the php file.
    We can help you implement captcha, but it is a paid service.

    Support Team

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Captcha by BestWebSoft
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic