Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > ColdFusion > Javascript vali...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 1661 of 1694
Post > Topic >>

Javascript validation in CF

by ll <barn104_1999@[EMAIL PROTECTED] > Apr 27, 2007 at 08:13 AM

Hi,
I am working with a page that has both cfform elements and 'plain
html' form elements.  In particular, I am needing to validate my
textarea form field and my email text field.  On one of my html pages,
I have been using a great javascript validation script; however, I am
wondering if I can use that in a coldfusion page?  I've included the
javascript I'd been using before.
Thanks for any help you can provide,
Regards,
Louis

In the cfform tag, I included this call:
<cfform action="#cgi.script_name#" method="Post" name="NewItemForm"
onSubmit="return checkWholeForm(this)" >

The javascript in the head is listed below:
-----
<script language="JavaScript">
// news headline/email subject
function checkEmailSubject (strng) {
var error="";
if (strng == "") {
   error = "Please enter an Email Subject/News Headline.\n\n";

}

// news/email content
function checkContent (strng) {
var error="";
if (strng == "") {
   error = "Please enter Email/News Content.\n\n";

}

// email
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Please enter your email address.\n\n";

}

//filter for ou/ouhsc domains
    var emailFilter2=/.@[EMAIL PROTECTED]
(ou|ouhsc)\.edu$/i
    if (!(emailFilter2.test(strng)))    {
    error="Please enter a valid email address with either ou or ouhsc
domain.\n\n";
    }
//end domain filter

    var emailFilter=/^.+@[EMAIL PROTECTED]
    if (!(emailFilter.test(strng))) {
       error = "Please enter a valid email address.\n\n";
    }
        else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n
\n";
       }

    }
return error;

}

<!-- Begin check form script, which refers to above -->

function checkWholeForm(NewItemForm) {
    var why = "";
        why += checkEmail(NewItemForm.Email1.value);
        why += checkEmailSubject(NewItemForm.EmailSubject.value);
        why += checkContent(NewItemForm.Content.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

// -->
</script>
<!-- End form validation script -->
 




 4 Posts in Topic:
Javascript validation in CF
ll <barn104_1999@[EMAI  2007-04-27 08:13:29 
Re: Javascript validation in CF
Bob Dively <dive@[EMAI  2007-04-27 15:30:38 
Re: Javascript validation in CF
ll <barn104_1999@[EMAI  2007-04-27 12:12:03 
Re: Javascript validation in CF
Bob Dively <dive@[EMAI  2007-04-27 19:32:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 13:39:53 CDT 2008.