Registration Form Validation

OK, I finally conquered the Java Validation of the Registraion Form.  It will now validate the Fixed Fields as well as all the auto fields that are set to required.  As I know some of you are eager for this solution, I will give it here, but it will be included in my next release.

To replace the code yourself, open the file event_register_attendees.inc.php (if you don’t have that file in your folder you have an old version, please upgrade to a newer version).  Go to line 109 and look for the ‘<SCRIPT>’.  Select all the text between ‘<SCRIPT> and ‘</SCRIPT>’ (but not the  ’<SCRIPT> and ‘</SCRIPT>’) and delete the existing validation script. 

Next copy and paste the code at the bottom of this post in between the ‘<SCRIPT> and ‘</SCRIPT>’.  Then Save, Upload and try it out.

If you found this helpful, please provide me your comments and if you can any donations would be appreciated.

Donate

Do you find Event Registration plugin useful?

Amount: $

 


 

//Function to check the format of the email address

function echeck(str) {
  var at=”@”
  var dot=”.”
  var em = “”
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)

  if (str.indexOf(at)==-1){ return false;}

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false;}

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false;}

  if (str.indexOf(at,(lat+1))!=-1){return false;

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false;}

  if (str.indexOf(dot,(lat+2))==-1){return false;}
 
  if (str.indexOf(” “)!=-1){return false;}

  return true;    
}
function validateForm(form) {

//MSG is the basis to put all alerts in if a field is missing
 
 var msg = “”;

//Validate the standard form fields

 if (form.fname.value == “”) {  msg += “\n ” +”Please enter your first name.”;
      form.fname.focus( );
      }

 if (form.lname.value == “”) {  msg += “\n ” +”Please enter your last name.”;
      form.lname.focus( );
      }
 
 if (echeck(form.email.value)==false){msg += “\n ” + “Email format not correct!”;}
 
 if (form.phone.value == “”) {  msg += “\n ” +”Please enter your phone number.”;
 form.phone.focus( );
 }

 if (form.address.value == “”) {  msg += “\n ” +”Please enter your address.”;
      form.address.focus( );
      }

 if (form.city.value == “”) {  msg += “\n ” +”Please enter your city.”;
      form.city.focus( );
      } 
 
 if (form.state.value == “”) { msg += “\n ” + “Please enter your state.”;
      form.state.focus( );
      }

 if (form.zip.value == “”) {  msg += “\n ” +”Please enter your zip code.”;
      form.zip.focus( );
       }
   
//Validate Extra Questions – Radio & Checkbox & Text

 function trim(s) {if (s) {return s.replace(/^\s*|\s*$/g,”");} return null;}
   
  var inputs = form.getElementsByTagName(“input”);
  var e;

 for( var i = 0, e; e = inputs[i]; i++ ){
  var value = e.value ? trim(e.value) : null;
 
    if (e.type == “text” && e.title && !value && e.className == “r”)
    {msg += “\n ” + e.title;}
 
 
   if ((e.type == “radio” || e.type == “checkbox”) && e.className == “r”) {
       var rd =”"
       var controls = form.elements;
     
   function getSelectedControl(group)
         {
         for (var i = 0, n = group.length; i < n; ++i)
          if (group[i].checked) return group[i];
          return null;
        }
     
  if (!getSelectedControl(controls[e.name]))
        {msg += “\n ” + e.title;}
     }
 }

//Validate Extra Questions – Textarea

  var inputs = form.getElementsByTagName(“textarea”);
  var e;
 
  for( var i = 0, e; e = inputs[i]; i++ ){
    var value = e.value ? trim(e.value) : null;
    if (!value && e.className == “r”)
    {msg += “\n ” + e.title;}
  }

//Validate Extra Questions – DropDown

 var inputs = form.getElementsByTagName(“select”);
  var e;
 
 for( var i = 0, e; e = inputs[i]; i++ ){
    var value = e.value ? trim(e.value) : null;
    if ((!value || value ==”) && e.className == “r”)
    {msg += “\n ” + e.title;}
  }

//Return the Alert Message – if exists

 if (msg.length > 0) {
    msg = “The following fields need to be completed before you can submit.\n\n” + msg;
    alert(msg);
    return false;
   }
 
//If no Alert message release form for posting

return true; 

}

 


 

 

Do you find Event Registration plugin useful? How about giving back a little?

 Amount: $

Posted in Form Validation, Uncategorized | Leave a comment

New Feature – Images with Events

I have added (version 3.04) the ability to put thumbnails and header images associated with events. Pretty cool. You will need upload your images using your FTP or other method. All you have to do to use is place the link in the event setup page. The Event listing link is 4×3 aspect. I recommend your image for the thumbnail be 150×112. For the header bar image on the registration page, that should be no wider than 450. I recommend 450 x 150 for the header image. Please let me know what you think.event-with-image

Posted in Uncategorized | 6 Comments

Mail Issue

Emails sent by the plugin say wordpress@yourdomain.com
The email thing is a default WordPress thing, not related to my plugin.

There is a great little plugin that resolves that issue.
http://wordpress.org/extend/plugins/mail-from/

Posted in Mail, Troubleshooting, Uncategorized | 2 Comments

Export Issue

I get this error:
Fatal error: Call to undefined function get_option() in /testserver/wordpress/wp-content/plugins/event-registration/event_registration_export.php on line 24
The reason you are getting that error is that wordpress is not installed in the root directory of your website. The plugin was written assuming it would be in the root installation. In the plugin folder there is a file called event_registration export.php you will need to change line 3.
Current:
3. define( ‘ABSPATH’, $_SERVER['DOCUMENT_ROOT'] . ‘/’ );
Modified:
3. define( ‘ABSPATH’, $_SERVER['DOCUMENT_ROOT'] . ‘/your_subdirectory_name

Posted in Export, Troubleshooting, Uncategorized | 5 Comments