Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

jQuery Form Validation


jQuery Form Validation
<script>
function validate()
{
var name= jQuery("#user_name").val();
var title= jQuery("#title").val();
var email= jQuery("#email").val();

var letters = /[A-Za-z]+$/;
var emailPattern1 = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
  if(name=='')
  {
    jQuery('#user_name').val('');
jQuery('input[name$="user_name"]').attr('placeholder', 'Enter Your Full Name:');
jQuery('#user_name').css('border-color', 'red');
jQuery( "#user_name" ).focus();
return false;
  }
    else  if(!name.match(letters))
  { jQuery('#user_name').val('');
jQuery('input[name$="user_name"]').attr('placeholder', 'Enter the Valid Full Name');
jQuery('#user_name').css('border-color', 'red');
jQuery( "#user_name" ).focus();
return false;
  }
 
      if(title=='')
  { jQuery('#user_name').css('border-color', '#e4e4e4');
jQuery('#title').css('border-color','red');
jQuery( "#title" ).focus();
return false;
  }
   
/*   else {
  var phonenoformat = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;              
  if(!(phonenoformat.test(phone))) {
 jQuery('#country').css('border-color', '#e4e4e4');
    jQuery('#phone').val('');
jQuery('input[name$="phone"]').attr('placeholder', 'Enter Valid Phone No:');
jQuery('#phone').css('border-color', 'red');jQuery( "#phone" ).focus();
return false;
  }
  } */
/*  else if(isNaN(phone))
{jQuery('#country').css('border-color', '#e4e4e4');
    jQuery('#phone').val('');
jQuery('input[name$="phone"]').attr('placeholder', 'Enter Valid Phone No:');
jQuery('#phone').css('border-color', 'red');jQuery( "#phone" ).focus();
return false;
}    */

/*    else {
   var faxnumbers = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;      
    if (!(faxnumbers.test(fax)))
{
jQuery('#phone').css('border-color', '#e4e4e4');
    jQuery('#fax').val('');
jQuery('input[name$="fax"]').attr('placeholder', 'Enter valid Fax:');
jQuery('#fax').css('border-color', 'red');jQuery( "#fax" ).focus();
return false;
}
  } */
    if(email=='')
  { jQuery('#fax').css('border-color', '#e4e4e4');
    jQuery('#email').val('');
jQuery('input[name$="email"]').attr('placeholder', 'Enter your Email:');
jQuery('#email').css('border-color', 'red');jQuery( "#email" ).focus();
return false;
  }
 else if(emailPattern1.test(email) == false) // && emailpattern!=Email)
  { jQuery('#fax').css('border-color', '#e4e4e4');
    jQuery('#email').val('');
jQuery('input[name$="email"]').attr('placeholder', 'Enter Valid Email:');
jQuery('#email').css('border-color', 'red');jQuery( "#email" ).focus();
return false;
  }

 
submit_data();
}



 function submit_data(){
   jQuery.ajax({
          type:"POST",
          data:jQuery("form").serialize(),
          url: "register_user.php",
          success: function(value) {
 if(value==1) {

 jQuery("#successmessage").show();
 jQuery("#registration_form")[0].reset();

 }
          },
  error: function(xhr, textStatus, errorThrown){
           //alert('request failed');
           }
        });

}
</script>
<form action="" name="registration_form"  id="registration_form" method="POST" onsubmit=""  >
 
   <span id="successmessage" style="display:none">You have successfully registered</span>

<p>
                  <label>Please choose what you are registering as:</label>
                  <select name="title" id="title">
   <option  value="">Select</option>
                    <option  value="Sponsor">Sponsor</option>
                    <option  value="Exhibitor">Exhibitor</option>
             
             
                  </select>
                </p>

      <p>
                  <label>Name</label>
                  <input type="text" name="user_name" id="user_name"  />
                </p>
           
                <p>
                  <label>Phone</label>
                  <input type="text" name="phone" id="phone" />
                </p>
           
                <p>
                  <label>Email</label>
                  <input type="text" name="email" id="email" />
                </p>
     

                <p class="register_submit">
                 <input type="button" onclick="return validate();" name="submit_reg_form" value="Submit">
                </p>
           
</form>

Comments

Popular posts from this blog

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);    ...

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_pro...