How to check validation for email field in sencha touch?Here my code in application,Please help me to solve this
{
xtype: 'fieldset',
items:[{
xtype: 'emailfield',
inputType:'email',
labelWidth: '33%',
label: 'Email',
id:'emailId',
name: 'emailId',placeHolder:'emailId'}]
}
If you storing fields as model instance, you can do.
Ext.define('User', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'name', type: 'string'},
{name: 'emailId', type: 'string'}
{name: 'phone', type: 'string'}
]
},
validations: [
{type: 'presence', name: 'name',message:"Enter Name"},
{type: 'format', name: 'emailId', matcher: /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, message:"Wrong Email Format"}
]
});
Or you can just match with regular expression
var ereg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var testResult = ereg.test(emailId);
testResult
will be true or false based on validation.