Page 1 of 1
[SOLVED]Form Builder How to prevent submition if value exist
Posted: Tue Apr 30, 2013 3:09 am
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
Re: Form Builder 0.7.3 - How to prevent submition if value e
Posted: Tue Apr 30, 2013 1:49 pm
by velden
Regex validation is possible on text input -> Advanced tab.
Re: Form Builder 0.7.3 - How to prevent submition if value e
Posted: Tue Apr 30, 2013 8:55 pm
by blackhawk
I will look into that. Thank you for the tip.
Re: Form Builder 0.7.3 - How to prevent submition if value e
Posted: Wed May 15, 2013 2:00 pm
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!
Re: Form Builder 0.7.3 - How to prevent submition if value e
Posted: Wed May 15, 2013 2:06 pm
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();
}
});
Re: Form Builder 0.7.3 - How to prevent submition if value e
Posted: Wed May 15, 2013 2:13 pm
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
Re: Form Builder 0.7.3 - How to prevent submition if value e
Posted: Wed May 15, 2013 3:37 pm
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
Re: [SOLVED]Form Builder How to prevent submition if value e
Posted: Fri May 17, 2013 9:56 am
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.
Re: [SOLVED]Form Builder How to prevent submition if value e
Posted: Fri May 17, 2013 10:44 am
by blackhawk
Understood. Thanks for the good tip!