-
27 Jul 2012 7:22 AM #1
Answered: How can i check the validation?
Answered: How can i check the validation?
Hello, I want to make a valid check function when the user presses the button.
For example, the user didn't choose the end time like that.
can i get some sample codes to follow or an advice?
I only found version 3 extjs sample code
this is my code.
Code:{ xtype: 'form', name: 'scheduleForm', url: 'http://localhost/ci_extjs_crud/index.php/user/addSchedule', items: [{ xtype: 'fieldset', height: 500, width: 629, title: 'Enter New Schedule', items: [{ store: companyData, //mode: 'local', xtype: 'combobox', fieldLabel: 'Company Name', dataIndex: 'companyName', displayField: 'companyName', valueField: 'companyName', name: 'companyName', anchor: '100%' }, { store: activityData, xtype: 'combobox', fieldLabel: 'Activity Name', dataIndex: 'activityName', displayField: 'activityName', name: 'activityName', anchor: '100%' }, { xtype: 'datefield', fieldLabel: 'Start Date', format: 'Y-m-d', anchor: '100%', name: 'startDate' }, { xtype: 'timefield', fieldLabel: 'Start Time', format: 'H:i', anchor: '100%', name: 'startTime' }, { xtype: 'datefield', fieldLabel: 'End Date', format: 'Y-m-d', anchor: '100%', name: 'endDate' }, { xtype: 'timefield', fieldLabel: 'End Time', format: 'H:i', anchor: '100%', name: 'endTime' }, { xtype: 'button', text: 'Save', handler: function() { this.up('form').getForm().submit(); Ext.Msg.show({ title: 'Status', msg: 'Success!', icon: Ext.MessageBox.INFO, width: 300 }); //window.location.reload(); } }] }] }
-
Best Answer Posted by scottmartin
You can use options like: allowBlank, vtypes, validate... check on the form level form.isValid, etc
There are many options depending on your requirement.
ex: vtype for phone:
Scott.Code:Ext.apply(Ext.form.VTypes, { phone: function(v) { var phoneRegex = /^\d{3}-\d{3}-\d{4}$/; return phoneRegex.test(v); }, phoneMask: /[\d-]/, phoneText: 'Invalid: ###-###-####' });
-
27 Jul 2012 9:07 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
You can use options like: allowBlank, vtypes, validate... check on the form level form.isValid, etc
There are many options depending on your requirement.
ex: vtype for phone:
Scott.Code:Ext.apply(Ext.form.VTypes, { phone: function(v) { var phoneRegex = /^\d{3}-\d{3}-\d{4}$/; return phoneRegex.test(v); }, phoneMask: /[\d-]/, phoneText: 'Invalid: ###-###-####' });


Reply With Quote