Validate email only if field is not empty

How do I validate an email field (with correct email content) only if something is being filled in?

If I add validate=“ValidEmail” I must enter a valid email address, I can’t leave the field blank. How do I achieve this?

you may try to create a custom rule for a validation:

http://docs.dhtmlx.com/doku.php?id=dhtmlxform:it_valid#validation_rules

I guess that validation of content and fields that may be empty or not should be logically separated. Like: … mandatory = “true” validate=“ValidEmail” …

How do I use your standard rules within a custom function? Is there an example?

TRy to use such custom validation rule:

function isValidMail (value) {
if(!value)
return true
return !!value.match(/(^a-z@([a-z_.])([.][a-z]{3})$)|(^a-z@([a-z_-.])(.[a-z]{2,3})$)/i);
}

o.k. … thanks

Means that standard rules for validations can’t be used in custom functions?

Yes, you need to define own rule that the existent doesn’t fit