Yeah, looks like you did the same thing I did in my example. You have
to wrap the javascript function in a cffunction. Not a big deal, but
it seems sloppy to me.

On Feb 11, 11:49 pm, Alex Skinner <[email protected]> wrote:
> Hey Aaron,
>
> Remember that less post I did a while ago, that might have what you need?
>
> Cheers. A
>
> On Sunday, 12 February 2012, Aaron J. White <[email protected]> wrote:> 
> Hey Guys,
>
> > Wasted a few minutes with this so I just wanted to make sure I'm not
> > crazy.
> > The documentation on this page (
>
> http://www.openbd.org/manual/?/cfscript_javascript
>
>
>
>
>
>
>
>
>
> > ) makes it seem like you can use a javascript function just like a
> > cffunction call inside a cfcomponent. But you can't?
>
> > The below does not work for me. I get an error.
> > <cfcomponent>
> >  <cfscript language="javascript">
> >                function looksLikeMail(str) {
>
> >                        var lastAtPos = str.lastIndexOf('@');
> >                        var lastDotPos = str.lastIndexOf('.');
> >                        return (lastAtPos < lastDotPos && lastAtPos > 0 &&
> > str.indexOf('@@') == -1 && lastDotPos > 2 && (str.length - lastDotPos)
> >> 2);
> >                }
> >        </cfscript>
> > </cfcomponent>
>
> > The below does work:
>
> >  <cffunction name="isMail" access="public" returntype="boolean">
> > <cfargument name="str" type="string" required="yes" />
> >         <cfscript language="javascript">
> >                function looksLikeMail(str) {
>
> >                        var lastAtPos = str.lastIndexOf('@');
> >                        var lastDotPos = str.lastIndexOf('.');
> >                        return (lastAtPos < lastDotPos && lastAtPos > 0 &&
> > str.indexOf('@@') == -1 && lastDotPos > 2 && (str.length - lastDotPos)
> >> 2);
> >                }
> >        </cfscript>
> > <cfreturn looksLikeMail(arguments.str) />
> > </cffunction>
>
> > --
> > online documentation:http://openbd.org/manual/
> >   google+ hints/tips:https://plus.google.com/115990347459711259462
> >    http://groups.google.com/group/openbd?hl=en
>
> >     Join us @http://www.OpenCFsummit.org/Dallas, Feb 2012
>
> --
> Alex Skinner
> Managing Director
> Pixl8 Interactive
>
> Tel: +448452600726
> Email: [email protected]
> Web: pixl8.co.uk

-- 
online documentation: http://openbd.org/manual/
   google+ hints/tips: https://plus.google.com/115990347459711259462
     http://groups.google.com/group/openbd?hl=en

     Join us @ http://www.OpenCFsummit.org/ Dallas, Feb 2012

Reply via email to