Thanks.  I'll check it out.

  _____  

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: LaRell Nielsen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 04, 2005 5:59 PM
To: [email protected]
Subject: RE: OT: JavaScript Help...


Here are a couple of JavaScript functions that can help in writing
JavaScript validations. Case in point the space check Matt mentioned.

function LTrim(in_data){
        var out_data,index;
        
        out_data = in_data;
        
        while (out_data.length > 0){
                sChar = out_data.charAt(0);
                
                if(sChar == " "){
                        out_data = out_data.substr(1);
                } else {
                        break;
                }
        }
        
        return out_data;
}

function RTrim(in_data){
        var out_data,index;
        
        out_data = in_data;
        
        while (out_data.length > 0){
                sChar = out_data.charAt(out_data.length - 1);
                        
                if(sChar == " "){
                        out_data = out_data.substr(0,out_data.length - 1);
                } else {
                        break;
                }
        }
        
        return out_data;
}

function Trim(in_data){
        return RTrim(LTrim(in_data));
}

The call formatting is the same as CF so in Matts' function you could alter
it like so:

function textValidate(field) {
var checkValue = Trim(field.value)
        if (checkValue.length == 0) {
                alert("Please enter some text in " + field.name);
                return false;
        }
}

-----Original Message-----
From: "Alford, Gary L" <[EMAIL PROTECTED]>
Sent: Jan 4, 2005 10:59 AM
To: "'[email protected]'" <[email protected]>
Subject: RE: OT: JavaScript Help...

Wonderful.  I'll give this a try.

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: Matt Woodward [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 04, 2005 9:22 AM
To: [email protected]
Subject: Re: OT: JavaScript Help...


"This" might help. ;-)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>

<script language="javascript">
        function textValidate(field) {
                if (field.value.length == 0) {
                        alert("Please enter some text in " + field.name);
                        return false;
                }
        }
</script>
</head>

<body>
<form>
        Field 1: <input type="text" name="field1"
onBlur="textValidate(this);" /><br />
        Field 2: <input type="text" name="field2"
onBlur="textValidate(this);" /><br />
</form>
</body>
</html>

Bear in mind that if you're checking to see if the user entered
anything at all, you also need to handle if they just enter spaces,
which a length check won't catch.  I have an "isBlank" function laying
around somewhere that checks both length and checks for space
input--let me know if you're interested in that and I'll dig it up.

Matt

On Tue, 4 Jan 2005 08:31:42 -0600, Alford, Gary L
<[EMAIL PROTECTED]> wrote:
> 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
> 
> 


-- 
Matt Woodward
[EMAIL PROTECTED]
http://www.mattwoodward.com
----------------------------------------------------------
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

----------------------------------------------------------
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