inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 5, 2013 16:42:58 GMT -8
How would I go about stopping the post submit if certain criteria are not met? And then once they met the criteria the post will submit?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 5, 2013 18:25:56 GMT -8
criteria such as?
you can always hide the submit buttons. or if you REALLY want to be efficient, change the action of the posting form.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 5, 2013 18:32:10 GMT -8
Well its for the thread description plugin. And I'm adding in an option to have it so the description is forced to be entered, and if you click submit and the thread description input isn't filled then it won't submit.
How would I do the changing the action of the posting form?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 5, 2013 20:21:30 GMT -8
if its something like THAT then I wouldnt change the action, just hide the submit button. then its easy to unhide it on a keyup or something in the description field.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Aug 6, 2013 0:54:28 GMT -8
Why not bind a "validated" event, and then just return false if the description field is not filled out?
Or worse case, bind a "submit" event, just make sure you preventDefault and stopPropagation on the event.
One of those should work, unless something has changed since I last looked at them?
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 6, 2013 7:47:52 GMT -8
So I tried
$('form.form_thread_new').submit(function(e) { var description = $('input.thread_description_input').val(); if(description != ''+placholderText+'' && ((forceDescription && description != '') || !forceDescription)) { proboards.plugin.key('thread_description_key').set_on('thread_new',description); } else { proboards.alert('Please input a description.'); e.stopPropagation(); e.preventDefault(); } });
Once you click submit, you can't submit it anymore. So it doesn't work. And I tried replacing
e.stopPropagation(); e.preventDefault();
with return false;
and it does the same as the first code. It won't submit anymore. Am I doing something wrong?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Aug 7, 2013 1:25:09 GMT -8
Something must have changed with validated and submit, as I used to use them for the Monetary System until set_on was added. I haven't used them since, but in theory returning false (which basically does preventDefault and stopPropagation) should work. Maybe Tim Camara can explain?
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Aug 7, 2013 9:54:59 GMT -8
We have some code built into our forms that runs on every submit call to disable the button that submits the form. This is intended to stop double-submissions, but also has the side effect of disabling form submission. To get around this, just make sure you also re-enable the submit button at the appropriate time.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 7, 2013 10:54:22 GMT -8
Thanks Tim Camara! I tried every possible location for it in the code, but no where did it want to work. I suppose because the button didn't have the disabled property set yet. So I used a setInterval function to do it. Thanks for all the help guys I appreciate it!
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Aug 7, 2013 11:20:05 GMT -8
You could also try un-disabling the button with an change event on the field you're checking
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 7, 2013 11:25:08 GMT -8
You could also try un-disabling the button with an change event on the field you're checking That works too. Dunno why I didn't think that.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 10, 2013 16:42:31 GMT -8
Tim Camara is there a way to block the captcha pop up when a guest is posting? Only block it until the field is filled and once it passes that it can pop up and be entered?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Aug 10, 2013 17:04:05 GMT -8
This may be a better idea. I gave it a quick test, and it seems to work fine. I've added comments so you can see what to change...
$(".form_thread_new").data("form").options.validations.push({ field: "message", // The field to validate against message: "Testy", // The message to show name: "testy", // Function to call opts: {} // Other options (exists etc) });
// Function needs to be prefixed with "check_"
$.check_testy = function(){ console.log(arguments); // First param is the value of the field return false; // stops form submitting and captcha showing };
Edit: Just remember to return true in the validation function if everything validates.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Aug 10, 2013 18:13:55 GMT -8
So what you posted works just fine if i run it in the console. But when in the actual plugin. It says "TypeError: Cannot read property 'options' of undefined"
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 10, 2013 19:32:36 GMT -8
the form hasnt been created yet or its running on a page without the form.
|
|