473,698 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript validation for mixed form

ll
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.sc ript_name#" method="Post" name="NewItemFo rm"
onSubmit="retur n checkWholeForm( this)" >
The javascript in the head is listed below:
-----
<script language="JavaS cript">
// news headline/email subject
function checkEmailSubje ct (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=/.@(ou|ouhsc)\.e du$/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=/^.+@.+\..{2,3}$/;
if (!(emailFilter. test(strng))) {
error = "Please enter a valid email address.\n\n";
}
else {
//test email for illegal characters
var illegalChars= /[\(\)\<\>\,\;\:\ \\"\[\]]/
if (strng.match(il legalChars)) {
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(NewI temForm.Email1. value);
why += checkEmailSubje ct(NewItemForm. EmailSubject.va lue);
why += checkContent(Ne wItemForm.Conte nt.value);
if (why != "") {
alert(why);
return false;
}
return true;
}
// -->
</script>
<!-- End form validation script -->

Apr 26 '07 #1
1 1652
ll said the following on 4/26/2007 4:50 PM:
Hi,
I am working with a page that has both cfform elements and 'plain
html' form elements.
There is no such thing as a "cfform element" in HTML. What you use on
the server is irrelevant. What is relevant is what the browser gets. So,
post a sample URL to a generated page and not Cold Fusion code.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2683
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
2
1453
by: GIMME | last post by:
Background ... I've created a web application that allows a user to create an HTML application from IE. The application itself creates an XML representation of a XHTML form. The XHTML representation can be saved as a string and recreated. (The application also has a crude workflow aspect - so XMHTML forms can be created and assigned a workflow. Forget I said anything about
4
9468
by: Madha K | last post by:
I am developing a web application that need to support UTF-8 characters. For client side validations, can javascript be used to handle UTF-8 characters. 1) How javascript can be used to restrict non-utf8 characters? 2) Using javascript how to find the lengh of a string having unicode characters? e.g: For a field Name on the form, there is a corrosponding field Name varchar2(10) in DB. Through my application when i try enter 10 normal...
5
2135
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a roundtrip to the server. The codebehind seems to be unaware of select box members populated via javascript. So, I'm having to create my own state management solution, (i.e. rewriting the VIEWSTATE mechanism) to persist the state of these select...
1
3255
by: IkBenHet | last post by:
Hello, Currently I am using a large input form on a website that is based on ASP and JavaScript. Depending on the values that are filled in by the user the forms does a refresh and makes other input fields available to fill in. I use the JavaScript OnChange function (=clientside) that creates a querystring and does a refresh of the page. It works fine.
5
2643
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation was done and was successful. Any ideas? TIA!
1
6399
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there should be getRateQuote, and QUOTEREQUEST, etc.
27
4745
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it may be because much of the form is populated with data from the db (lists, etc.), but when I leave...
5
19074
by: cbs7 | last post by:
Hi all I'm a complete newbie to web development and Javascript especially. I've been creating a form for a webpage and have used a validation script gen_validatorv2.js which I downloaded from the zip file referenced on http://www.javascript-coder.com/html-form/javascript-form-validation.phtml I managed to get everything working and was testing through Firefox that alerts were generated. However at the very end I thought I'd better check...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.