This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
jquery validation
Started 14 years ago by fabiopao | 11 posts |
-
hi, I am trying to add a jquery validation plugin to my form, to make sure data entered in the fields are correct before user submits them: but in order to make this possible, I need to append a small class, say class="validate(required)" to the fields I want to validate. Is this possible, is there a file I can modify so that I can implement this function?
I'd really appreciate any helpPosted 14 years ago # -
Hi,
Basically you can add jQuery/javascript code in "view-functions.php" file. But it's depending on how the code works.
Anyway could you show me more detail about this script ? or perhaps you can show me the url for example .
MachForm Support
Posted 14 years ago # -
Hi, thanks for the reply. I am trying to use this plugin: http://demos.usejquery.com/ketchup-plugin/#what on the form i have put on my website: http://www.quadrifogliorosso.com
as you can see, the plugin needs to hook form elements with a specified class, and i don't know how to do it.
CheersPosted 14 years ago # -
I think it's possible to use that plugin, but it will take a lot of modification. To do this, you need to edit "view-functions.php" file and in this example, I assume you'll use the validation for "single line text" field with element id 1 on form 2.
Try to follow these steps :1. Copy all ketchup plugin to mahform js folder, then the path should be like this :
/machform/js/ketchup-plugin
2. Go to line 1833, you'll see this code :
{$calendar_js}
then put these code bellow that line
<link rel="stylesheet" type="text/css" media="screen" href="js/ketchup-plugin/css/jquery.ketchup.css" /> <script type="text/javascript" src="js/ketchup-plugin/js/jquery.min.js"></script> <script type="text/javascript" src="js/ketchup-plugin/js/jquery.ketchup.js"></script> <script type="text/javascript" src="js/ketchup-plugin/js/jquery.ketchup.messages.js"></script> <script type="text/javascript" src="js/ketchup-plugin/js/jquery.ketchup.validations.basic.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#form_2').ketchup(); }); </script>
3. Go to line 40 for this code :
$element_markup = <<<EOT
then put this code above that line
if ($_GET['id'] == 2 && $element->id == 1 ) { $ketchup = ' validate(required) '; }
4. Go to line 46, you'll see this code :
<input id="element_{$element->id}" name="element_{$element->id}" class="element text {$element->size}" type="text" value="{$element->default_value}" />
change to
<input id="element_{$element->id}" name="element_{$element->id}" class="$ketchup element text {$element->size}" type="text" value="{$element->default_value}" />
don't forget to change those id with yours
MachForm Support
Posted 14 years ago # -
I tried to quickly integrate this but got the following error in the console:
Error: $.fn.ketchup is undefined
Source File: js/ketchup-plugin/js/jquery.ketchup.validations.basic.js
Line: 86Posted 14 years ago # -
Have you download "ketchup-plugin" and extract the file like in the step 1 ?
MachForm Support
Posted 14 years ago # -
Yes, i kept getting an error, have you made this work with ketchup?
-Sam
Posted 14 years ago # -
this is the error I keep getting,
Error: $.fn.ketchup is undefined
Source File: js/ketchup-plugin/js/jquery.ketchup.validations.basic.js
Line: 86I have everything extracted and followed the exact instructions, I would be greatful if you could help, I will put the example up again here in a few mins.
Posted 14 years ago # -
I have made the exact changes above,
My question is, what do I have to do in the above code to make it work with my form.
Here is my form: http://www.virtualbrix.com/form-lead-management/embed.php?id=3
I checked the Firefox console and I get this:
Warning: Unknown property 'border-radius'. Declaration dropped.
Source File: http://www.virtualbrix.com/form-lead-management/js/ketchup-plugin/css/jquery.ketchup.css
Line: 13AND
Error: $.fn.ketchup is undefined
Source File: http://www.virtualbrix.com/form-lead-management/js/ketchup-plugin/js/jquery.ketchup.validations.basic.js
Line: 86I would be grateful if you can help,
-Sam
Posted 14 years ago # -
I think you didn't change the ID's from my example code. I see in your form, these code ;
$(document).ready(function() { $('#form_2').ketchup(); });
should be changed to
$(document).ready(function() { $('#form_3').ketchup(); });
because you're using the validation for form 3.
However, if the problem still persist, is it possible to send me your FTP login into to :customer.service[at]appnitro.com
I will help you to check it
MachForm Support
Posted 14 years ago # -
sent you an email,
-Samer
Posted 14 years ago #
Reply
You must log in to post.