Joomla 5 Mitteilung

Wir freuen uns mitteilen zu können, dass seit dem 29. Januar 2024 alle unsere Joomla Erweiterungen mit Joomla 5 kompatible sind.

Für alle die gerade noch von Joomla 3 auf 4 aktualisieren: Anleitungen für die Joomla 4 Migration gibt es hier:

Es gibt nun auch eine eigenständige Dokumentation für Visforms für Joomla 4 und für Visforms auf Joomla 5

Forum

Visforms Subscription Inhaber können in unserem Forum Fragen stellen. Bitte mit dem entsprechenden Benutzer anmelden.
Jeder kann lesend auf das Forum zugreifen.

Bitte stellen Sie nur 1 Frage pro Thema.

Wichtig Angaben für fast jede Frage:
V1: Welche Visforms-Version läuft?
V2: Welche Joomla-Version läuft?
V3: Welche PHP-Version läuft?

Stop Form Submission

Mehr
8 Jahre 2 Wochen her #3707 von perryworld
Stop Form Submission wurde erstellt von 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

Mehr
8 Jahre 2 Wochen her #3708 von Administrator AV
Administrator AV antwortete auf 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 :-).

Moderatoren: Administrator AVAdministrator IV
Powered by Kunena Forum