PDA

View Full Version : allowBlank ignored in Form



paulr
11 Aug 2010, 9:45 PM
Hey there,

i created a form with fieldsets and textfields.

in each of the textfields i specify allowBlank : false;

one of the textfields has vtype : email.

When i try to submit a blank form, it does not complain at all. BUT if i enter invalid input to the email textfield, it will complain saying that the format must be "[email protected]" ,which basically is my vtypetext.

Please advice me on how to fix this.

Thanks in advance

stv-linux
15 Aug 2010, 9:55 AM
Hi, I think you must add in the handler function of the submit buttom



if (yourForm.getForm().isValid()){
yourForm.getForm().submit()
}

Bye

paulr
15 Aug 2010, 7:08 PM
@stv-linux : i tried that and still doesn't work.

so far i declared my fieldset with xtpe fieldset and textfield with xtype textfield.

It does check for the validation but does not check the allowBlank.
Is there anything that you need me to supply to help me solve this?

thanks in advance


Hi, I think you must add in the handler function of the submit buttom



if (yourForm.getForm().isValid()){
yourForm.getForm().submit()
}

Bye

stv-linux
15 Aug 2010, 9:40 PM
Hi, try this code:




Ext.onReady(function(){

Ext.QuickTips.init();


var movie_form = new Ext.FormPanel({
url: 'movie-form-submit.php',
renderTo: document.body,
frame: true,
title: 'Movie Information Form',
width: 250,
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
name: 'title',
allowBlank: false
},{
xtype: 'textfield',
fieldLabel: 'Director',
name: 'director',
allowBlank: false
},{
xtype: 'datefield',
fieldLabel: 'Released',
name: 'released'
}],
buttons: [{
text: 'Save',
handler: function(){
if (movie_form.getForm().isValid()){

movie_form.getForm().submit({
success: function(f,a){
Ext.Msg.alert('Success', 'It worked');
},
failure: function(f,a){
Ext.Msg.alert('Warning', 'Error');
}
});
}else{
Ext.Msg.alert('Warning', 'Please, fill all field');
}


}
}, {
text: 'Reset',
handler: function(){
movie_form.getForm().reset();
}
}]

});
});




Bye