PDA

View Full Version : Ext Js isValid function is not working.



deb440
2 Aug 2013, 12:33 AM
Hi All,

This my first post in the forum. I am new to Extjs I am trying to implement registration form multiple user based on radion button Selection. For First two form (this.candidateRegistration,this.jobseekerRegistration,) everyting is woring fine but from 3rd form( this.instituteRegistration, this.companyRegistration, this.partnerRegistration) isValid method is not working. I am getiing "


TypeError: this.regex.test is not a function



chrome://firebug/content/blank.gif


if (this.regex && !this.regex.test(a)) {



" in the firebug when I click on Register button. Please help.

this.mandatoryForm = new Ext.FormPanel({
labelAlign : 'top',
frame : true,
bodyStyle : 'padding:5px 5px 0',
items:[{
layout : 'column',
items : [{
//Some Fields
},{
layout : 'form',
xtype : 'radiogroup',
columnWidth : .8,
fieldLabel : '<span class="mandatory">*</span>Usertype',
width : '100%',
//height : '10%',
id : 'userType',
allowBlank : false,
msgTarget : 'side',
blankText : 'userType is required',
items : [{
boxLabel : 'Student',
name : 'userType',
width :150,
id : 'student_user',
inputValue : 'Student',
listeners: {
check: function(checked) {
if(checked.getValue()){
Ext.getCmp('jobseekerRegistration_id').setVisible(false);
Ext.getCmp('candidateRegistration_id').setVisible(false);
Ext.getCmp('partnerRegistration_id').setVisible(false);
Ext.getCmp('companyRegistration_id').setVisible(false);
Ext.getCmp('instituteRegistration_id').setVisible(false);
Ext.getCmp('candidateRegistration_id').setVisible(true);
}else{
Ext.getCmp('candidateRegistration_id').setVisible(false);
}
}
}
},{
boxLabel : 'Job seeker',
name : 'userType',
width :150,
id : 'jobSeeker',
inputValue : 'Job Seeker',
listeners: {
check: function(checked) {
if(checked.getValue()){
Ext.getCmp('candidateRegistration_id').setVisible(false);
Ext.getCmp('partnerRegistration_id').setVisible(false);
Ext.getCmp('companyRegistration_id').setVisible(false);
Ext.getCmp('instituteRegistration_id').setVisible(false);
Ext.getCmp('jobseekerRegistration_id').setVisible(true);
}else{
Ext.getCmp('jobseekerRegistration_id').setVisible(false);
}
}
}
},{
boxLabel : 'Institute',
name : 'userType',
// width
// :150,
id : 'institute_user',
inputValue : 'Institute',
listeners: {
check: function(checked) {
if(checked.getValue()){
Ext.getCmp('candidateRegistration_id').setVisible(false);
Ext.getCmp('jobseekerRegistration_id').setVisible(false);
Ext.getCmp('partnerRegistration_id').setVisible(false);
Ext.getCmp('companyRegistration_id').setVisible(false);
Ext.getCmp('instituteRegistration_id').setVisible(true);
}else{
Ext.getCmp('instituteRegistration_id').setVisible(false);
}
}
}
},{
boxLabel : 'Company',
name : 'userType',
// width
// :150,
id : 'company',
inputValue : 'Company',
listeners: {
check: function(checked) {
if(checked.getValue()){
Ext.getCmp('candidateRegistration_id').setVisible(false);
Ext.getCmp('jobseekerRegistration_id').setVisible(false);
Ext.getCmp('instituteRegistration_id').setVisible(false);
Ext.getCmp('partnerRegistration_id').setVisible(false);
Ext.getCmp('companyRegistration_id').setVisible(true);
}else{
Ext.getCmp('companyRegistration_id').setVisible(false);
}
}
}
},{
boxLabel : 'Partner',
name : 'userType',
// width
// :150,
id : 'partner_user',
inputValue : 'Partner',
listeners: {
check: function(checked) {
if(checked.getValue()){
Ext.getCmp('candidateRegistration_id').setVisible(false);
Ext.getCmp('jobseekerRegistration_id').setVisible(false);
Ext.getCmp('instituteRegistration_id').setVisible(false);
Ext.getCmp('companyRegistration_id').setVisible(false);
Ext.getCmp('partnerRegistration_id').setVisible(true);
}else{
Ext.getCmp('partnerRegistration_id').setVisible(false);
}
}
}
}]
}]
}]
});
this.candidateRegistration = new Ext.FormPanel({
// Some Field
});
this.jobseekerRegistration = new Ext.FormPanel({
//Some Field
});
this.instituteRegistration = new Ext.FormPanel({
frame : true,
hidden : true,
id: 'instituteRegistration_id',
bodyStyle : 'padding:5px 5px 0',
items: [ this.createTextField('Name', '80%', 20,"Name", false, 20,
/^[a-zA-Z\s.]*$/,'Name is required')
]
});

this.companyRegistration = new Ext.FormPanel({
//Some Field
});
this.partnerRegistration = new Ext.FormPanel({
//Some Field
});
this.termsPanel= new Ext.FormPanel({
//Some Field
});
this.candidateRegForm = new Ext.FormPanel({
items:[this.mandatoryForm,this.candidateRegistration,this.jobseekerRegistration,
this.instituteRegistration,this.companyRegistration,this.partnerRegistration,this.termsPanel],
buttons : [ {
text : 'Register',
id : 'next-wondow',
listeners : {
'click' : function(field, event) {
var radioUser=localObject.mandatoryForm.getForm()
.findField("userType").getValue();
var selectUser=radioUser.getRawValue();
if(selectUser=='Student'){
localObject.onFormDataEntered();
}else if(selectUser=='Job Seeker'){
localObject.onFormDataEntered();
}else if(selectUser=='Company'){
localObject.onFormDataEntered();
}else if(selectUser=='Partner'){
localObject.onFormDataEntered();

}
}
}
}, {
text : 'Reset',
handler : function() {
localObject.onDataCleared();
}
} ]
});

localObject.onDataCleared();
},

onFormDataEntered : function(uploadedFileId) {

var localObj = this;
if (!this.mandatoryForm.getForm().isValid()) {
return;
}
if (!this.termsPanel.getForm().isValid()) {
return;
}
var radioUser=this.mandatoryForm.getForm()
.findField("userType").getValue();
var selectUser=radioUser.getRawValue();
if(selectUser=='Student'){
if (!this.candidateRegistration.getForm().isValid()) {
return;
}
}else if(selectUser=='Job Seeker'){
if (!this.jobseekerRegistration.getForm().isValid()) {
return;
}
}else if(selectUser=='Institute'){
if (!(this.instituteRegistration.getForm().isValid())) {
alert(this.instituteRegistration.getForm().isValid());
return;
}

}else if(selectUser=='Company'){
if (!this.companyRegistration.getForm().isValid()) {
return;
}
}else{
if (!this.partnerRegistration.getForm().isValid()) {
return;
}
}
}

createTextField : function(label, labelWidth, labelHeight, id,
allowBlank, blankText, maxLength, nameExp) {
var fieldLabel = label;
if (!allowBlank) {
fieldLabel = '<span class="mandatory">*</span>' + label;
}

return textVar = new Ext.form.TextField({
id : id,
allowBlank : allowBlank,
blankText : blankText,
maxLength : maxLength,
msgTarget : 'side',
fieldLabel : fieldLabel,
labelSeparator : ':',
width : labelWidth,
height : labelHeight,
regex : nameExp
});
},

slemmon
5 Aug 2013, 7:57 AM
Is "mandatoryForm" what is having an issue on the validation check?