[SOLVED]Form Builder How to prevent submition if value exist

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

[SOLVED]Form Builder How to prevent submition if value exist

Post by blackhawk »

Within CMSMS 1.11.4, and Form Builder 0.7.3, I'm trying to setup the following condition for a specific input text field:

If the user fills out this specific field, then don't submit the form.

Is this conditional process possible within Form Builder? If so, how can I incorporate this?

Thanks for any advice!
bh
Last edited by blackhawk on Wed May 15, 2013 3:39 pm, edited 1 time in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Form Builder 0.7.3 - How to prevent submition if value e

Post by velden »

Regex validation is possible on text input -> Advanced tab.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: Form Builder 0.7.3 - How to prevent submition if value e

Post by blackhawk »

I will look into that. Thank you for the tip.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: Form Builder 0.7.3 - How to prevent submition if value e

Post by blackhawk »

Velden, thanks for the feedback, but is there a JavaScript location built into Form Builder where we can validate submitted values before the submission is successful?

For example, if I have a text input field called animals, and someone wrote cat into that field, I could then detect the text value is 'cat' with JavaScript and then either cancel the submission process or do nothing. Where would the appropriate panel be located for this type of action in Form Builder?

Thanks!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Form Builder 0.7.3 - How to prevent submition if value e

Post by calguy1000 »

Easy enough to do with jquery in the form template. something like:

Code: Select all

$('form').submit(function(e){
  var f = $(this).find('#YOURFIELDSID');
  if( typeof f != 'undefined' && $(f).val() != '' ) {
     alert('error message');
     $(e).preventDefault();
  }
});
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Form Builder 0.7.3 - How to prevent submition if value e

Post by Wishbone »

I'm assuming that this is for spam prevention... If so, jQuery might not work that well.

http://forum.cmsmadesimple.org/viewtopi ... ct#p277766
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: Form Builder 0.7.3 - How to prevent submition if value e

Post by blackhawk »

Thank you calguy1000 for displaying how easy it is to integrate custom jQuery with Form Builder! That was a root question in the back of my mind, and you just confirmed it for me. Thanks!

Thank you Wishbone for that post. You're jedi powers read through my mind and that was exactly what I was looking for because I am note comfortable yet apply regular expression to form fields...I spend most of my day developing with javascript...

But anyway, thank you guys! I feel like I'm learning new stuff everyday! Cool.

blackhawk
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [SOLVED]Form Builder How to prevent submition if value e

Post by velden »

I think Javascript is pretty useless for spam prevention this way.

I'd think spam bots just post their data the the form handler, so no javascript is involved at all.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: [SOLVED]Form Builder How to prevent submition if value e

Post by blackhawk »

Understood. Thanks for the good tip!
Post Reply

Return to “Modules/Add-Ons”