JavaScript Error on Regex Rule

42 views
Skip to first unread message

Matt Quackenbush

unread,
Dec 12, 2010, 1:27:15 PM12/12/10
to valida...@googlegroups.com
VT 0.97.5
jQuery 1.4.2
Validate Plugin 1.6.0 (or 1.7.0; both have the same result)

When I create a regex rule, I am getting a JavaScript error on page load.  Here is the offending line...

jQuery.validator.addMethod("ticketpurchaseformLineOneregex", jQuery.validator.methods.regex, "Please provide your physical address.  Seller will not ship to a post office box.");

The error message is: "method is undefined".

Here is a screencap from Firebug... http://www.quackfuzed.com/VT_regex_javascripterrror_stack.png

If I remove the regex rule, the error also vanishes.  Add the rule back in, and the error is back.  I _really_ need to use regex here and I _really_ need to get this off my plate in very short order, so any help in getting this resolved would be sincerely appreciated!  :-)

Thanks in advance.

Matt Quackenbush

unread,
Dec 12, 2010, 1:44:39 PM12/12/10
to valida...@googlegroups.com
In looking at the jQuery Validation plugin documentation page here, http://docs.jquery.com/Plugins/Validation/Validator#List_of_built-in_Validation_methods, it appears to me that the problem is caused by VT referencing a 'regex' method, which, as seen in the list on that page, does not exist.  I'm sure other people are using regex rules without issue, so something in my environment must be amiss.

The particular regex I am using is very long, and is unrelated (any regex rule throws the same error), so I am not pasting the actual regex, but here is the rule from my XML file...

<rule type="regex" contexts="*" failureMessage="Please provide your physical address.  Seller will not ship to a post office box.">
    <param name="regex" value="^(regex here)$" />
</rule>


adam drew

unread,
Dec 12, 2010, 5:54:48 PM12/12/10
to valida...@googlegroups.com
Matt,

how are you setting up jQuery and the validator plugin on your page? are you doing it manually and/or using VT's getInitializationScript()?
could you pastebin the <script> headers on the rendered page giving you trouble?


Regards,
Adam





--
You received this message because you are subscribed to the Google Groups "ValidateThis" group.
To post to this group, send email to valida...@googlegroups.com.
To unsubscribe from this group, send email to validatethis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/validatethis?hl=en.

Matt Quackenbush

unread,
Dec 12, 2010, 6:08:50 PM12/12/10
to valida...@googlegroups.com
Quasi-manual setup...

1) jQuery already loaded (on all pages).

2) cfUniForm loads the validation plugin and then calls VT's getValidationScript() and loads it.

(One of these days I will find [create?] some time to release these new updates to cfUniForm.  But I digress.)

adam drew

unread,
Dec 12, 2010, 6:15:16 PM12/12/10
to valida...@googlegroups.com
Matt,

In version 097.5, the custom client rules (like regex and isBoolean) are hared coded into VT's getInitialiaztionScript result.. if you don't call it you are SOL for Boolean and Regex rules on the client side.. In version 0.98 I've modified this behavior to allow client types to dynamically provide the validator methods for the initialization scripts, but you still need to call getInitializationScript() on the page in either case to have VT's custom client rule methods available.... (regex & isCFBoolean)

1) jQuery loaded for all page,
2) cfUniFormLoads the validation plugin and sets any defaults.
3) call vt.getInitializationScript(includeJS=false);  //  this should fix your issue on v0.97.5
4) call vt.getValidationScript();

Let me know if that works out..

regards,
adam

adam drew

unread,
Dec 12, 2010, 6:18:32 PM12/12/10
to valida...@googlegroups.com
BTW, there were numerous bug-fixes and client rule scripter enhancements in v0.98 that might be worth your gander.

Matt Quackenbush

unread,
Dec 12, 2010, 6:38:29 PM12/12/10
to valida...@googlegroups.com
Wow!  Yeah baby!  That totally did the trick!  Thanks!

Now then, since this is kinda crucial to make sure I don't screw up the cfUniForm + VT integration, am I correctly understanding that I can safely call getInitializationScript(includeJS=false) even if no "custom" rules are being used?  My initial very quick testing says 'yes', but since you know that portion pretty intimately, I figured I'd ask directly.  :-)

adam drew

unread,
Dec 12, 2010, 6:43:57 PM12/12/10
to valida...@googlegroups.com
Honestly, I'm not using cfUniForm.. so i would hate to just say YES without testing it..    but since I am using my own custom FormGenerator based on the transfer.codegen package and custom templates.. and I set up jquery and all plugins manually.. based on that.. I will say YES, even if no "custom" rules are defined, you NEED to call getInitializationScript(includeJS=false) regardless.

please do share with me any problems you run into here so i can further improve VT for integration with cfUniForm and my EntityFormGenerator.cfm all at the same time :)

Regards,
Adam






On Sun, Dec 12, 2010 at 6:38 PM, Matt Quackenbush <quack...@gmail.com> wrote:
Wow!  Yeah baby!  That totally did the trick!  Thanks!

Now then, since this is kinda crucial to make sure I don't screw up the cfUniForm + VT integration, am I correctly understanding that I can safely call getInitializationScript(includeJS=false) even if no "custom" rules are being used?  My initial very quick testing says 'yes', but since you know that portion pretty intimately, I figured I'd ask directly.  :-)

Matt Quackenbush

unread,
Dec 12, 2010, 6:48:40 PM12/12/10
to valida...@googlegroups.com
On Sun, Dec 12, 2010 at 5:43 PM, adam drew wrote:
Honestly, I'm not using cfUniForm..


GASP!  BLASPHEMY!!!!!!!!!!!!!!  :D

 
but since I am using my own custom FormGenerator based on the transfer.codegen package and custom templates.. and I set up jquery and all plugins manually.. based on that.. I will say YES, even if no "custom" rules are defined, you NEED to call getInitializationScript(includeJS=false) regardless.


Gotcha.  Done.  :-)


please do share with me any problems you run into here so i can further improve VT for integration with cfUniForm and my EntityFormGenerator.cfm all at the same time :)


Sounds like a plan.  ;-)

Matt Quackenbush

unread,
Dec 16, 2010, 4:33:34 PM12/16/10
to valida...@googlegroups.com
For those following along at home, I found today that the argument name changed somewhere between 0.97.5 and 0.98.1.  So, instead of...

includeJS=false

... you need to use...

JSIncludes=false

HTH

Bob Silverberg

unread,
Dec 16, 2010, 4:41:54 PM12/16/10
to valida...@googlegroups.com
I hate to argue with a satisfied user, but according to my source
control repository JSIncludes was added in version 0.96 and has never
changed.

Cheers,
Bob

> --
> You received this message because you are subscribed to the Google Groups
> "ValidateThis" group.
> To post to this group, send email to valida...@googlegroups.com.
> To unsubscribe from this group, send email to
> validatethis...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/validatethis?hl=en.
>

--
Bob Silverberg
www.silverwareconsulting.com

adam drew

unread,
Dec 16, 2010, 5:08:51 PM12/16/10
to valida...@googlegroups.com
looks like my dyslexia struck again. sorry.

Matt Quackenbush

unread,
Dec 16, 2010, 5:41:35 PM12/16/10
to valida...@googlegroups.com
All I know is that I was using 0.97.5 and includeJS=false did the trick.  Upgrading to 0.98.1 caused it to no longer work and I had to switch to JSIncludes=false.  No argument, just stating pure and simple facts.  <shrug>

Matt Quackenbush

unread,
Dec 16, 2010, 5:43:48 PM12/16/10
to valida...@googlegroups.com
No apology necessary.  I was merely trying to help out folks who might read this thread later.
Reply all
Reply to author
Forward
0 new messages