Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Form Validation using Custom Thread Fields
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Form Validation using Custom Thread Fields
Hi

I am building a form in my prefix_newthread template using XThreads custom fields, and I am a bit stuck on the validation of the form.

I have a select box (values are Yes or No). Default value is No, div id is "cerem". When the value YES is selected then another div on the page (div id "cerem2") opens showing a second select box(values 0,1,2). (It would be nice to be able to CLOSE that div if they then choose NO after all, but thats a nice to have, not a must have).

The idea is if the answer NO is inputted then the user should not choose a number. But they can still choose a number with NO selected.  What I would like is that when the user submits the form then if there are combinations such as

No and a number greater than 0
or
Yes and 0

that the page will not submit but instead will give an error (like the error we get if we try to upload an invalid attachment).

This combination of Yes and No (with different ids) occurs 4 times on the page -

Is this possible? If so, can anyone give me some pointers on how to achieve this? I have added a picture of the form....


Attached File(s) Thumbnail(s)
   


[Image: leelink.gif]
MYBB1.6 & XThreads
02-27-2011 05:14 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: Form Validation using Custom Thread Fields
I thought you've finished it?
What happens to your javascript?

02-27-2011 08:45 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #3
RE: Form Validation using Custom Thread Fields
XThreads can't do conditional inputs, only outputs, so you'll need to use conditionals to check if it's Yes/No when displaying, rather than it being posted.  Alternatively, use one field and use Javascript to put in the Yes/No button rather than a threadfield.  Basically, add something like (Not attending) to the number of guests list.

Note that Javascript can't exactly enforce it since users can simply disable it.

My Blog
02-27-2011 09:08 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Form Validation using Custom Thread Fields
I've tried creating a simple form "wizard", using conditional (Template Conditional or PHP In Template plugin). But it is not a Javascript form Oops :

http://www.14.mynie.co.cc/newthread.php?fid=49

The form "system" is something like this (I hope):
   
It is a bit hard to explain it, so, I "draw" it.

Maybe it is a very bad form wizard, breakable with direct URL Biggrin

(This post was last modified: 02-27-2011 11:16 AM by RateU.)
02-27-2011 10:23 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Form Validation using Custom Thread Fields
(02-27-2011 08:45 AM)RateU Wrote:  I thought you've finished it?
What happens to your javascript?

Yea, I thought I had finished it too.......

The thing is, I kind of knew that this MIGHT be an issue. Its not the appearing - thats done. Its that users can select being two guests while saying they are not coming to the party. Frown

Of course, its easy to filter and so on, so if there is a problem we can see it, and we have to assume that the users have a brain, but I just wanted to know if it could be fixed as it is BAD DESIGN on my part that users CAN input contradictory data.

I can pretty easily make a form that does all these things not using XThreads - but I wanted the data in the db to query it, and to show on the first post and in the thread display yadda yadda. I also LIKE XThreads.


WHOA - I just tested out the wizard RateU - thats really cool - and it works Smile

Re breakable - yea, most of the users are like mums and dads - and a couple of smart alecs. First one of those who says its not very good I will offer them the address to the FTP and the SQL database and tell THEM to do it.....


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 02-27-2011 11:31 AM by leefish.)
02-27-2011 11:19 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Form Validation using Custom Thread Fields
But the form wizard "not work" in edit post. It is hard (for me) to make it "work" in editpost Biggrin
What I mean is, when a user edit the thread, it will displaying the usual editpost, not in a wizard form style (step by step form).......

02-28-2011 05:03 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Form Validation using Custom Thread Fields
Yea, edit post was an area where I was growling a bit.....

Its still awesomely cool and I will install the set up and show my friend - this way she can choose. I will see if I can apply my usual ability to steal other people's idea to this editpost thing Smile


[Image: leelink.gif]
MYBB1.6 & XThreads
02-28-2011 03:20 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: