Also an excellent method.

Thanks for the help.

  _____  

Gary L. Alford
Manufacturing Operations Project Specialist
Bell Helicopter XWorx
Phone: (817) 280-6233     Fax: (817) 278-6233
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> 

I have not failed.  I've found 10,000 ways that won't work.
          Thomas A. Edison 
  _____  



-----Original Message-----
From: Seth Bienek [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 04, 2005 9:18 AM
To: [email protected]
Subject: RE: JavaScript Help...


Hey Gary,

Not off-topic at all..  And it's pretty easy to make this validation
generic:

<html>
<head>
  <title>Untitled</title>
  <script language="JavaScript">
    <!-- 
    function validateNotEmpty(formelement,description) 
      {
      if (formelement.value.length < 1) {       window.alert(description) };
      } 
    // -->
  </script>
</head>
<body>
<form name="form1">
  <input type="Text" name="text1" onblur="validateNotEmpty(this, 'Please
enter a value for Text 1');">
  <input type="Text" name="text2" onblur="validateNotEmpty(this, 'Whatever
message you want to pop up');">
</form>
</body>

In JavaScript, everything is basically an object, so when you have two
objects of the same type (text input form elements in this
case) that have the same properties, and that need to be acted upon in the
same manner, it makes a lot of sense to have them share a
function, and have them identify themselves to that function so it knows
which object to act on.  In this example, the input
identifies itself by passing 'this' into the validation function, which is a
JS object's way of saying 'me'.  Hope that makes sense.

Best Regards,

Seth

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Alford, Gary L
> Sent: Tuesday, January 04, 2005 8:32 AM
> To: DFW ColdFusion Users Group (E-mail)
> Subject: OT: JavaScript Help...
> 
> Happy New Year!
> 
> Excuse me for going a little off topic, but I am a bit confused...
> 
> Please consider the following:
> 
>       <html>
>       <head>
>               <title>Untitled</title>
>               <script language="JavaScript">
>                       <!-- 
>                       function _validateText1() {
>                               var validate = 
> document.form1.text1.value;
>                               if (validate.length < 1) {
>                                       window.alert("Please 
> enter a value
> for Text 1.");
>                               }
>                       }
>                       function _validateText2() {
>                               var validate = 
> document.form1.text2.value;
>                               if (validate.length < 1) {
>                                       window.alert("Please 
> enter a value
> for Text 2.");
>                               }
>                       }
>                       // -->
>               </script>
>       </head>
>       <body>
>       <form name="form1">
>               <input type="Text" name="text1" 
> onblur="_validateText1()">
>               <input type="Text" name="text2" 
> onblur="_validateText2()">
>       </form>
>       </body>
>       </html>
> 
> Is there a way to dynamically send the form name and input 
> box name to the JavaScript functions as variables so I only 
> have to write one function that would validate all input text 
> boxes in the form?  Is there a better way to do an input 
> validation on an "onblur" event that what I am trying to do? 
> Is there a CF tag that can perform this same function easier 
> on an "onblur"
> event?  I know I can use <cfform... and <cfinput... and 
> specify the required attribute, but this only appears to 
> validate upon form submittal and it is requested to perform 
> this validation on a blur event - prior to form submittal.
> 
> Any help would be appreciated.
> 
>   _____  
> 
> Gary L. Alford
> Manufacturing Operations Project Specialist Bell Helicopter XWorx
> Phone: (817) 280-6233     Fax: (817) 278-6233
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> 
> 
> I have not failed.  I've found 10,000 ways that won't work.
>           Thomas A. Edison
>   _____  
> 
> ----------------------------------------------------------
> To post, send email to [email protected]
> To unsubscribe: 
>    http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
> To subscribe: 
>    http://www.dfwcfug.org/form_MemberRegistration.cfm
> 
> 
> 

----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm

----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm


Reply via email to