jQuery: The Write Less, Do More JavaScript Library

(validate) Customising bassistance validation plugin

View: New views
5 Messages — Rating Filter:   Alert me  

(validate) Customising bassistance validation plugin

by Iwan Vosloo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

We are trying to use the validation plugin with HTML that's been
generated for us.  There are a couple of things we'd like to customise
if we can for the plugin to work with this HTML.

One of them is that the code uses some HTML5 conventions - like how to
specify when an input is required:

Usually you'll have something like:
<input type="text" class="required">

In our HTML, we'd have:
<input type="text" required>

Is there a way to customise/configure the validation plugin to
recognise the latter?

Thanks
- Iwan

Re: (validate) Customising bassistance validation plugin

by Jörn Zaefferer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The plugin by default picks up attributes, so if you're using attribute names that match validation plugin methods, it should work like that. Though you may need to also provide a value, ala required="true", not sure about that.

Jörn

On Sat, Nov 7, 2009 at 6:21 AM, Iwan Vosloo <iwan@...> wrote:
Hello,

We are trying to use the validation plugin with HTML that's been
generated for us.  There are a couple of things we'd like to customise
if we can for the plugin to work with this HTML.

One of them is that the code uses some HTML5 conventions - like how to
specify when an input is required:

Usually you'll have something like:
<input type="text" class="required">

In our HTML, we'd have:
<input type="text" required>

Is there a way to customise/configure the validation plugin to
recognise the latter?

Thanks
- Iwan


Re: (validate) Customising bassistance validation plugin

by Iwan Vosloo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jörn,

On Nov 7, 3:28 pm, Jörn Zaefferer <joern.zaeffe...@...>
wrote:
> The plugin by default picks up attributes, so if you're using attribute
> names that match validation plugin methods, it should work like that. Though
> you may need to also provide a value, ala required="true", not sure about
> that.

This works for validation methods, but not for the required...

Regards
- Iwan

Re: (validate) Customising bassistance validation plugin

by Iwan Vosloo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah,

I got it working... The value of the "required" attribute should be a
dependency-expression (http://docs.jquery.com/Plugins/Validation/
Methods/required#dependency-expression  )

So, required="true" does not work.  I'm still trying to figure out
what else can be in there / what exactly a dependency-expression is,
but it seems that the following works (although I'd like to understand
still...):

required=":true"
required="{:true}"
required="{anynamehere:true}"
required="{:anystringhere}"

-i

On Nov 9, 2:14 pm, Iwan Vosloo <i...@...> wrote:

> Hi Jörn,
>
> On Nov 7, 3:28 pm, Jörn Zaefferer <joern.zaeffe...@...>
> wrote:
>
> > The plugin by default picks up attributes, so if you're using attribute
> > names that match validation plugin methods, it should work like that. Though
> > you may need to also provide a value, ala required="true", not sure about
> > that.
>
> This works for validation methods, but not for the required...
>
> Regards
> - Iwan

Re: (validate) Customising bassistance validation plugin

by Iwan Vosloo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Of course, its a jquery expression, what else...

However, I do think the docs may be wrong:  at
http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression

In the arguments section it reads:
"An expression (String) is evaluated in the context of the element's
form, making the field required only if the expression returns more
than one element."

Surely that should be "one or more elements"?

Regards
- Iwan