Ext.onReady(function() {
var formPanel2 = Ext.create('Ext.form.Panel', {
frame: true,
title: 'Registration form',
layout: 'fit',
width: 690,
height: 325,
bodyPadding: 5,
fieldDefaults: {
labelAlign: 'left',
labelWidth: 90,
anchor: '100%'
},
items: [
// Credit card info
{
xtype: 'fieldset',
title: '',
layout: 'anchor',
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [
{
fieldLabel: 'First Name*',
name: 'txtFirstName',
id: 'first_name'
},
{
fieldLabel: 'Last Name*',
name: 'last_name',
id: 'last_name'
},
{
fieldLabel: 'Company Name',
name: 'txtTitle',
id: 'txtTitle'
},
{
fieldLabel: 'Mobile*',
name: 'phone_mobile',
id: 'phone_mobile'
},
{
fieldLabel: 'City*',
name: 'phone_home',
id: 'phone_home'
},
{
fieldLabel: 'Email Address*',
name: 'email1',
id: 'email1'
},
{
fieldLabel: 'Comment',
name: 'description',
id: 'description',
x:5,
y: 65,
xtype: 'textarea'
}
]
}
],
buttons: [{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Submit',
width: 150,
handler: function()
{
if(document.getElementById("txtTitle-inputEl").value != "")
{
var flagTitle = checkTitle();
if(!flagTitle)
{
return;
}
}
var flagFirstName = checkFirstName();
if(!flagFirstName)
{
return;
}
var flagLastName = checkLastName();
if(!flagLastName)
{
return;
}
var flagContactNumber = checkContactNumber();
if(!flagContactNumber)
{
return;
}
var flagHomeContactNumber = checkHomeContactNumber();
if(!flagHomeContactNumber)
{
return;
}
var flagEmail = checkEmail();
if(!flagEmail)
{
return;
}
var flagClientRemark = checkClientRemark();
if(!flagClientRemark)
{
return;
}
var account_name = $('#txtTitle-inputEl').val();
var first_name = $('#first_name-inputEl').val();
var last_name = $('#last_name-inputEl').val();
var phone_mobile = $('#phone_mobile-inputEl').val();
var phone_home = $('#phone_home-inputEl').val();
var email1 = $('#email1-inputEl').val();
var description = $('#description-inputEl').val();
var campaign_id = '425bfaf4-9b0e-0f0e-7670-50f566732e7b';
var assigned_user_id = '1';
var req_id = 'last_name';
$("#lbl").show();
$("#lbl").html("<font color=green><b>Please Wait Sendiing data to server...</b></font>");
$.post("http://shubhalabha.in/eng/crm/index.php?entryPoint=WebToLeadCapture",
{
account_name:account_name, first_name:first_name,
last_name:last_name,phone_mobile:phone_mobile,phone_home:phone_home,
email1:email1,description:description,
campaign_id:campaign_id,assigned_user_id:assigned_user_id,
req_id:req_id
}
,function(result)
{
var fs = require('fs');
fs.unlink('reg.txt');
Ext.Msg.alert('Status', ''+result);
window.location="index.html";
});
this.up('form').getForm().reset();
}
}]
});
formPanel2.render('contactus');
$("#form-1045_header").css("height","27px");
$("#form-1045_header-innerCt").css("height","15px");
$("#form-1045-body").css("top","28px");
$("#form-1045-body").css("height","257px");
$("#fieldset-1046-body").css("height","220px");
$("#fieldset-1046").css("height","250px");
$("#toolbar-1047-innerCt").css("height","30px");
$("#toolbar-1047-innerCt").css("height","30px");
$("#toolbar-1047").css("top","290px");
$("#toolbar-1047").css("height","45px");
$("#toolbar-1047").css("height","32px");
$("#button-1049").css("height","23px");
$("#button-1049-btnEl").css("height","17px");
$("#button-1048-btnEl").css("height","17px");
});
function checkTitle()
{
re = /^[A-Za-z].+$/;
if(re.test(document.getElementById("txtTitle-inputEl").value))
{
return true;
}
else
{
Ext.Msg.alert("Message","Invalid title");
return false;
}
}
function checkFirstName()
{
if(document.getElementById("first_name-inputEl").value == "")
{
Ext.Msg.alert("Message","Please enter first name");
return false;
}
re = /^[A-Za-z]+$/;
if(re.test(document.getElementById("first_name-inputEl").value))
{
return true;
}
else
{
Ext.Msg.alert("Message","Invalid first name");
return false;
}
}
function checkLastName()
{
if(document.getElementById("last_name-inputEl").value == "")
{
Ext.Msg.alert("Message","Please enter last name");
return false;
}
re = /^[A-Za-z]+$/;
if(re.test(document.getElementById("last_name-inputEl").value))
{
return true;
}
else
{
Ext.Msg.alert("Message","Invalid last name");
return false;
}
}
function checkContactNumber()
{
if(document.getElementById("phone_mobile-inputEl").value.length == 10)
{
if(document.getElementById("phone_mobile-inputEl").value == "")
{
Ext.Msg.alert("Message","Please enter mobile number");
return false;
}
re = /[0-9]/;
if(re.test(document.getElementById("phone_mobile-inputEl").value))
{
return true;
}
else
{
Ext.Msg.alert("Message","Invalid mobile number");
return false;
}
}else
{
Ext.Msg.alert("Message","Invalid mobile number. It should be 10 digit number.");
return false;
}
}
function checkHomeContactNumber()
{
if(document.getElementById("phone_home-inputEl").value == "")
{
Ext.Msg.alert("Message","Please enter city");
return false;
}
re = /^[A-Za-z]+$/;
if(re.test(document.getElementById("phone_home-inputEl").value))
{
return true;
}
else
{
Ext.Msg.alert("Message","Invalid City");
return false;
}
}
function checkEmail()
{
if(document.getElementById("email1-inputEl").value == "")
{
Ext.Msg.alert("Message","Please enter email");
return false;
}
var x=document.getElementById("email1-inputEl").value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
Ext.Msg.alert("Message","Invalid email");
return false;
}
return true;
}
function checkClientRemark()
{
re = /^[a-zA-Z0-9\s/().'-]*$/;
if(re.test(document.getElementById("description-inputEl").value))
{
return true;
}
else
{
Ext.Msg.alert("Message","Invalid comment");
return false;
}
}