PDA

View Full Version : how to check in the form whether any filed is enterd



kamalakarreddy vancha
29 Oct 2014, 5:40 AM
HI.....
I have a Form, It contains number fo fields...... and I need validation as any one of field value shoud enter,field is not specifed...How it can be possible ? Please provide solution...

scottmartin
29 Oct 2014, 7:55 AM
You can use allowBlank for the field, or setup a vtype and then use form.isValid() to validate the fields. They will show with a red box around the field. You can also setup notices for each field.

In these examples, just hit save right away to see invalid fields:

http://docs.sencha.com/extjs/4.2.3/#!/example/form/fieldcontainer.html
http://docs.sencha.com/extjs/4.2.3/#!/example/form/dynamic.html
http://docs.sencha.com/extjs/4.2.3/#!/example/form/adv-vtypes.html

kamalakarreddy vancha
29 Oct 2014, 11:41 PM
Hi..
Thanks for replay....
Actually my requirement is...
i have a form with more than 20 fields and save, cancel buttons.
When i click the save button it is giving a massage like please enter any one field in the form.
For that i wrote a condition like...

var Title1 = Ext.getCmp('Title1Id').getValue();
var Title2 = Ext.getCmp('Title2Id').getValue();
var Title3 = Ext.getCmp('Title3Id').getValue();
var Title4 = Ext.getCmp('Title4Id').getValue();
var Title5 = Ext.getCmp('Title5Id').getValue();
var Title6 = Ext.getCmp('Title6Id').getValue();
if(!( Title1 || Title2 || Title3 || Title4 || Title5 || Title6)){
Ext.getCmp('Title1Id').markInvalid('Please provide a valid value of either Title1, or Title2 or Title3 to view the records');
Ext.getCmp('Title2Id').markInvalid('Please provide a valid value of either Title1, or Title2 or Title3 to view the records');
Ext.getCmp('Title3Id').markInvalid('Please provide a valid value of either Title1, or Title2 or Title3 to view the records');
Ext.getCmp('Title4Id').markInvalid('Please provide a valid value of either Title1, or Title2 or Title3 to view the records');
Ext.getCmp('Title5Id').markInvalid('Please provide a valid value of either Title1, or Title2 or Title3 to view the records');
Ext.getCmp('Title6Id').markInvalid('Please provide a valid value of either Title1, or Title2 or Title3 to view the records');
Ext.MessageBox.show({
title:'inValidFormTtl',
msg:'Please provide a valid value of either Title1, or Title2 or Title3',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR,
fn:function(){
Ext.getCmp('Title1Id').focus('', 200);
}
});
return false;

here i have only six fields that's why i am checking for only six fields.
If i have more fields then how to write the condition to check the form to enter any one field.
Help me in this....



Thanks
Kamalakar Reddy