PDA

View Full Version : Form validation error



susurs
29 Nov 2007, 4:03 PM
Hi!
Almost banging my head for few hours without success :(
Whay I am getting the error(Firebug) after pressing the 'talak' button:
simple.isValid is not a function
Using just an example code snippet it isn't working :( Using latest buid of extjs
code below:


var simple = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php',
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',

items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, new Ext.form.TimeField({
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
})
],

buttons: [{
text: 'Save'
},{
text: 'Cancel'
}]
});

simple.addButton('talak', function(){
if(simple.isValid()) {
Ext.MessageBox.alert('Info', 'All OK.');
}else{
Ext.MessageBox.alert('Errors', 'Please fix the errors noted.');
}
}, simple);

simple.render(document.body);

fay
30 Nov 2007, 2:29 AM
Have you checked the documentation for FormPanel (http://extjs.com/deploy/dev/docs/output/Ext.form.FormPanel.html)? There is no isValid() method; what you are looking for is the BasicForm isValid() (http://extjs.com/deploy/dev/docs/output/Ext.form.BasicForm.html), which is accessible via the getForm() method:


if(simple.getForm().isValid()) {
// ...
}

Just a hint, probably best to post 2.0 questions in the 2.0 forum (http://extjs.com/forum/forumdisplay.php?f=9) :)