View Full Version : Form Validation

12 Sep 2011, 6:51 AM
Hi everyone,

I'm stuck trying to validate a simple form. I know there's some examples on the web but can't get a single one working.

Here is what I did (some stuff is missing):

Ext.regModel('Type', {
fields: [
{ name: 'IdType', type: 'string' },
{ name: 'Type', type: 'string' },
validations: [
type: 'presence',
name: 'Type',
message: 'please insert'

var form = new Ext.form.FormPanel({
standardSubmit: false,
items: [
xtype: 'fieldset',
instructions: 'Please insert',
defaults: {
required: false,
items: [
xtype: 'textfield',
name: 'name',
id: 'name',
required: true,
label: 'Name'
}, ]

How do you validate this ? within the form ? outside the form ?

Thanks !

14 Sep 2011, 1:19 PM
You can create an instance of the model.
Next you can load the model instance to the form, see form.load().
on form submit, first sync the model instance with the form fields, then check model is valid like
Var errors =instance.validate()
if instance.isValid you can submit, if not you can iterate on errors, build an eror message and set message to fieldset instructions.

Hope that helps