1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    68
    Vote Rating
    0
    gigas01 is on a distinguished road

      0  

    Default 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();
    						}
    					}]
    				}]
    			}

  2. 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:

    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: ###-###-####'
    });
    Scott.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,112
    Answers
    678
    Vote Rating
    470
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    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:

    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: ###-###-####'
    });
    Scott.

Thread Participants: 1