Cool regex checks on DL / email

validate an email or DL

e.g.

 DL current & new name restrict to 60 chars

Omit _ (underscore) . (dot )

Trim Current and New not (no start or end space)

Current and New must not contain  < > ; , [ ] " ' no colons (“:”)

Current and New not to contain [ \ " | , / : < > + = ; ? * ']

Current and New not to contain @ (unless eMail)

Current and New not to contain \ % & * + / = ? { } | < > ( ) ; : , [ ] 


var sTrimmedValue = String (g_form.getValue(sFieldName)).trim(); if (/@/.test(sTrimmedValue)){ //email if (!/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/.test(sTrimmedValue)){ //--throw an error }
}else{ //DL if (sTrimmedValue.length > 60){ //--throw error } if (!/^([a-zA-Z])*$/.test(sTrimmedValue)){ //--throw error }else{ //--OK }

Comments

Popular posts from this blog

GlideRecord setValue

Running transform maps asynchronously

variable advanced reference qualifier example