PDA

View Full Version : form.isValid() NOT working



Pravin.Pawar
29 Jan 2013, 5:21 AM
Hi,

I have used regular expression over the ExtJS form. Regular expressions are working fine somehow I can submit the form.

It looks like; I will need to call form.isValid() on submit which is NOT working. I'm using following code-

var form = Ext.widget('form', {
ID: 'frmEvent',
layout: {
type: 'vbox',
align: 'stretch'
},
bodyBorder: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'left',
labelWidth: 120,
anchor: '100%',
margin: 5
},
items: [
new Ext.create('Ext.tab.Panel', {


],
buttons: [{
text: 'Submit',
type: 'submit',
id: 'btnSubmit',
listeners: {
scope: this,
click: function () {


I'm NOT getting isValid() method for the form. Please suggest me right approach to restrict submit action if any regular expression is failing.

Thanks, Pravin

sword-it
29 Jan 2013, 6:27 AM
Hi Praveen,

Try to the following code-


buttons: [{
text: 'Submit',
type: 'submit',
id: 'btnSubmit',
listeners: {
scope: this,
click: function () {
var form = this.getForm(); // try to get from panel reference
if(form.isValid()){
// do what you want
}
else{
alert('some form field is not valid');
}
}