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'}]
}
The proper way to activate validation directly in the view would be:
{
xtype: 'textfield',
name: 'email',
vtype: 'email'
}
No need for regex.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With