Skip to main content
Participating Frequently
Jan 4, 2009 11:30 AM UTC
Question

Java to Cold fusion (form email validation)

Hello to All!
For whom, who knows BOTH Regular expressions in JS and CF
I have:

<script type="text/javascript">
function isEmailCorrect(formname, fieldname) {

var re = /^\w+([\.-]?\w+)*@(((([a-z0-9]{2,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))+[a-z0-9]+\.([a-z]{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;

if(re.test(eval("document.forms['"+formname+"']."+fieldname+".value")))
return true;
else {
alert("Email is incorrect!");
eval("document.forms['"+formname+"']."+fieldname+".focus()");
return false;
}
}
</script>

I'm trying to do server validation and I'm going to use something like

<cfscript>
if (NOT REFindnocase(" EXPRESSION FROM JS ", email)) {
WriteOutput("error");
<cfscript>

But I don't no how to convert

" /^\w+([\.-]?\w+)*@(((([a-z0-9]{2,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))+[a-z0-9]+\.([a-z]{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i "

to the CF Regular expressions.

If somebody interested, you can see the "JS" action and idea on
http://www.web-utils.net/files/ex-check-email.html

Thanks to ALL!!!
    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    Inspiring
    Jan 4, 2009 1:33 PM UTC
    isValid("email", form.emailaddress)
    Translate