Form block - field identifier

Permalink
I'm trying to build a custom template for the form block that checks a few things.

One example - I'd like to check whether both mail fields contain the same value. How?

I tried to create a little javascript, but this doesn't work well because I have no idea how to find the mail fields ($("#???")). I could search after the label but the site has been built in 5 different languages, and what if the users changes the label?.. Bad idea.-

I need the flexibility of the form block, an external form isn't a solution.

Does anyone have an idea how I could solve that riddle?

Remo
 
synlag replied on at Permalink Reply
synlag
hi remo,

the selector for the input elements is

$(.formBlockSurveyTable input)

it returns an array with all input fields in .formBlockSurveyTable
Remo replied on at Permalink Reply
Remo
how does that solve my problem?

It returns 10 fields, 2 of them should contain a mail address.. I need to get only those fields that should contain an e-mail address, not all of them...
synlag replied on at Permalink Reply
synlag
just give your input fields an id in form_setup_html.php, which could correspond to the choosen label name (labelname changed -> id changed).

An idea?
Remo replied on at Permalink Reply
Remo
I can't use the label because this block must work with 5 different languages..
synlag replied on at Permalink Reply
synlag
ok, i thought the id could dynamically change to the choosen label.
I think it's not given to know at which position a user puts the email fields?
Or have they a static position (always last two input fields of a form block)?
Remo replied on at Permalink Reply
Remo
They great thing about the form block is the fact that the user can modify all the fields...

I might be able to fetch the 3rd and 4rd field today, but it might look different tomorrow. This is probably what I'm going to do until I've built a more advanced form block, but it's a bad solution because I probably forget about it and will fix it, if I get the next complaint (:
synlag replied on at Permalink Reply
synlag
There's only one possibility in my opinion, if we can't select by id or class.
We have to check what the input fields contain

$(.formBlockSurveyTable input:contains('@'))

this should return the two fields in an array...
Remo replied on at Permalink Reply
Remo
yeah that would work in a lot of situations. But it's also not the perfect solution:

- What if there's an @ in a different fields? Doesn't haven very often though..
- What if the user has forgotten the @ in the mail address?

I don't want to be too negative.. Okay, I am (: But even if these things don't happen very often, it's not a solution I'd like to use for all our projects...

But thanks anyways
synlag replied on at Permalink Reply
synlag
Have a look at the
jquery.validation.js plugin

This should do a good job client-side email validation.

Here's an example

http://tutorialblog.org/client-side-form-validation-with-jquery/...
Remo replied on at Permalink Reply
Remo
this is neat, but I still need id on my form elements...

(which I have, but I can't predict their name)
synlag replied on at Permalink Reply
synlag
perhaps this helps

http://stackoverflow.com/questions/345194/regular-expression-matchi...

Would you mind to post your solution when you got one?