JQuery Question

4 views
Skip to first unread message

Joseph Faisal Nusairat

unread,
Sep 30, 2009, 5:24:00 PM9/30/09
to colum...@googlegroups.com

hey all

Was trying to do jquery to do some dynamic validation and ran into a few problems.

Basically what i am trying to do is attach validations to classes and i want to add them only once.

so we hvae stuff like ->

Version:1.0
...
$.validator.addMethod("scoreMin", $.validator.methods.min,
        "${rt.compositeMessage(code: 'error.min', args: ['rule.score', ModelRiskRule.NUMBER_VALUE_MIN as String])}");
      $.validator.addMethod("scoreMax", $.validator.methods.max,
        "${rt.compositeMessage(code: 'error.max', args: ['rule.score', ModelRiskRule.NUMBER_VALUE_MAX as String])}");
      $.validator.addClassRules("score", { scoreRequired: true, scoreNumber: true, scoreMax:${ModelRiskRule.NUMBER_VALUE_MAX}, scoreMin:${ModelRiskRule.NUMBER_VALUE_MIN}});

-- adds the class rules

And this stuff works well displays an error message when it occurs. But what if i want in the error message to reference part of the field i am on.

I tried something like this ->
$.validator.addMethod("numberRequired", $.validator.methods.required,
        $.validator.format("Please enter the correct value for {1}"));

However this returns HTMLObjectInputElement...can I access the properties of that object ??
It doesnt seem like i can. {0} is true/ false.

Any ideas??

thanks joe




keif

unread,
Oct 1, 2009, 5:00:18 AM10/1/09
to Columbus Ruby Brigade
I'm assuming this is the plugin you're using?
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

From the site:
Please post questions to the jQuery discussion list, putting
“(validate)” into the subject of your post, making it easier to spot
it and respond quickly. Keep your question short and succinct and
provide code when possible; a testpage makes it much more likely that
you get an useful answer in no time.

And it goes ditto - if you have a test page, it'd be easier to take a
guess.

What exactly returns the HTMLObjectInputElement?

Have you tried throwing console.log() and see what Firebug shows?

-kb
Reply all
Reply to author
Forward
0 new messages