/// registration validation /////
$(document).ready(function() {
$("#reg_form").validate({
rules: {
fname: {// compound rule
required: true,
maxlength:80,
letterswithbasicpunc:true
},
lname: {// compound rule
required: true,
maxlength:80,
letterswithbasicpunc:true
},
email: {// compound rule
required: true,
email: true,
minlength:5,
maxlength:50
},
phone: {// compound rule
required: true,
minlength:5,
maxlength:50
},
postcode: {// compound rule
required: true,
minlength:4,
maxlength:50
},
hear_about: {
selectNone: true
},
security_code: {
required: true
},
query:{
required: true
}
},
messages: {
query: "Please enter query.",
fname: "
Please mention first name",
lname: "
Please mention last name",
email: "
Please mention email",
phone: "
Please mention phone",
postcode: "
Please mention postcode",
hear_about: "
Please mention from where did you hear about us"
}
}
);
});
$.validator.setDefaults({
submitHandler: function() {
/// sending data
var fname=document.reg_form.fname.value;
var lname=document.reg_form.lname.value;
var email=document.reg_form.email.value;
var phone=document.reg_form.phone.value;
var postcode=document.reg_form.postcode.value;
var hear_about=document.reg_form.hear_about.value;
var bed_room_val="";
var bed_room_all="";
var id=document.reg_form.id.value;
var reg_type=document.reg_form.reg_type.value;
//var bed_room=document.reg_form.bed_room.checked.value;
for (var i=0;i<3;i++)
{
if(document.reg_form.bed_room[i].checked)
{
bed_room_val=document.reg_form.bed_room[i].value;
bed_room_all=bed_room_all+bed_room_val+' , ';
}
}
// var price_range=document.reg_form.price_range.value;
// var security_code=document.reg_form.security_code.value;
// alert("B room"+bed_room_val);
// var callUrl='reg_mail.php?fname='+fname+'&email='+email+'&phone='+phone+'&postcode='+postcode+'&hear_about='+hear_about+'&security_code='+security_code+'&price_range='+price_range+'&bed_room='+bed_room_val+'&id='+id+'&today='+Math.random();
//var callUrl='reg_mail.php?fname='+fname+'&email='+email+'&phone='+phone+'&postcode='+postcode+'&hear_about='+hear_about+'&bed_room='+bed_room_all+'&id='+id+'®_type='+reg_type+'&today='+Math.random();
var callUrl='reg_mail.php?fname='+fname+'&lname='+lname+'&email='+email+'&phone='+phone+'&postcode='+postcode+'&hear_about='+hear_about+'&bed_room='+bed_room_all+'&id='+id+'®_type='+reg_type+'&today='+Math.random();
//alert(callUrl);
$.ajax({
url : callUrl,
success : function (data){
//alert("New msg "+data);
if(data==1){
window.location="index.php?id="+id+"&st=s";
}
else{
document.getElementById("mail_msg").innerHTML=data;
}
}
});
// end sedning data
}
});
////// end registration validation ////