<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
<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
Post a Comment