Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Important information for almost every question:
V1: Which Visforms version is running?
V2: Which Joomla version is running?
V3: Which PHP version is running?

Stop Form Submission

More
8 years 3 weeks ago #3707 by perryworld
Stop Form Submission was created by perryworld
Hi,

Is it possible to prevent a form from submitting based on our own validation.

We want to use jQuery to check against our database so when a user enters a number for "preferred no" we can check it hasn't already been allocated and if it has we do't want the form to submit and want to display our own message saying the number isn't available.

Any help would really be appreciated

Thanks
Richard

More
8 years 3 weeks ago #3708 by Administrator AV
Replied by Administrator AV on topic Stop Form Submission
Hi,

there is no such build in functionallity in Visforms.

Here are some options what you could do.

1) basically Visforms already has a unique values only validation for almost every field type. You can find it in the field configuration tab advanced. But the unique values validation is performed after the form was submitted and if it fails the form is re-displayed. The custom error message which you can store with the field is then not be used and if you want to override the php error message for unique value validation you have to use the Joomla! language manager. The langague tag is "COM_VISFORMS_UNIQUE_VALUE_REQUIRED"

2) The jQuery validator, which already validates all user inputs in the browser has a strong grasp on the submit event. Therefore the only way to add your own javascript to the submit event is, to make an override of the file, that includes the javascirpt which instanciates the validator Basically that is possible because I always kept the javascirpt code, that instanciates the validator in the views/layouts files of Visforms which can be overriden in your template. But I must warn you, in order to improve Visforms I (sadly) have to make changes to the view/layout files quite often and the changes sometimes are severe. So although you overrides are not touched be a Visforms update, you most probably will have to adapt them after a Visforms update or Visforms will be broken.

If you are on Visforms 3.7. you would have to add your javascript in the default.php file of the component or module (depending on which on you use to display the form).
components/com_visforms/views/visforms/tmpl or modules/mod_visforms/tmpl

There is something like
Code:
jQuery('#visform<?php echo $this->visforms->id; ?>').validate({ .... )};

You have to add a
Code:
submitHandler: function(form) { //your code in here form.submit(); },
object to this function.

On Visform 3.8 the code has moved to the components/com_visforms/layouts/visforms/scripts/validator.php file which is used be both, the component views and the module and can be overriden in the template, too.

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum