PDA

View Full Version : Multi validations VType email



Stupida
26 Oct 2012, 8:28 AM
Hi,
I've a probllem with email textfield on which I want to perform multi validations. In detail:
1. Classic format email validation
2. Unique email check

Can I override email VType? or I have to create a custom VType? How can I perform two validation with two different error messages in a single VType?

Thanks
Regards

mitchellsimoens
29 Oct 2012, 6:10 AM
Personally I would create my own vtype to handle it. You can still call the email vtype.

Stupida
30 Oct 2012, 1:14 AM
Hi, Thanks..
I'm trying to do this, but I can't!!
Why this simple custom vtype with 2 example of validations doesn't work?

Ext.apply(Ext.form.field.VTypes, {

email : function(v) {
var fileName = "cl@l.it";
var email = /^(\w+)([-+.][\w]+)*@(\w[-\w]*\.){1,5}([A-Za-z]){2,4}$/;

if(v != fileName){
emailText : "First Error";
return false;
}

else if(!email.test(v)){
emailText : "Second Error";
return false;
}
}
});

mitchellsimoens
30 Oct 2012, 1:20 AM
emailText : "First Error";

is not valid Javascript there. It should be like


emailText = "First Error";

Stupida
30 Oct 2012, 1:50 AM
doesn't work again!
I think "emailText :" is the correct way to define message error when return false...
how i can see in sencha vtype documentation
http://docs.sencha.com/ext-js/4-1/source/VTypes.html#Ext-form-field-VTypes

mitchellsimoens
30 Oct 2012, 2:47 AM
The post was put under moderation automatically, I have approved the first and deleted the duplicate, please read the message when you post to see if it was success or moderated.

Like I said, that is not valid JavaScript. The colon is only valid like that within an object, setting a value to a variable like you are you have to use an equal symbol. That's basic JavaScript. Look at the other variables you are setting.

Stupida
30 Oct 2012, 4:29 AM
Ok.
I can't set two error message in the emailText property.

Stupida
31 Oct 2012, 10:05 AM
Can everyone help me with a simple example?
Thanks