Force users to enter a phone or cell phone number before sending form the Wappler way

Hi Georg

Sorry, i have been working with wappler for a year but i am new to the forum.
I’m not sure to which address I can send my request to get an answer.

I want to force the user to enter a phone or mobile number. If he fills out both, that’s okay, if he doesn’t fill out either, an error message has to appear.

How can I “submit” this request.

Greetings
Toni

Hi @granjaj and welcome to the forums!

Here are some tutorials that should be able to help you.

For client-side validation, https://docs.wappler.io/t/validation-apply-client-side-form-validation-with-user-feedback/2849

For server-side validation, https://docs.wappler.io/t/server-side-validation/2848

Hallo Scott

Thanks for your help.

I’m already using the client-side validation, but the server-side validation not often.

I suppose I have to “build” something on the server side based on the conditions so that I can check if one of the two fields has been filled out, and if not, it returns an error message.

Greetings

Toni

You can use the server-side Validate Data component to require a form field and also set a regex pattern

Example pattern for phone numbers:

^[0-9\-\(\)\/\+\s]*$

Example phone numbers:
0821 12 34 567
08211234567
0821-1234567
0821-12 34 567
0821 - 1234567
0821 - 12 34 567
0821/1234567
0821/12 34 567
0821 / 1234567
0821 / 12 34 56 7
+49(821) 1234-567
+49 (821) 12 34 - 567

1 Like

Hi

Sorry I suppose I haven’t explained exactly what is my problem. I know the normal Validations-Steps and Patterns. So, I try to ask my question differently:

I have a registration form: name, e-mail validated against the database and so on. There are fields which I set to requested in the validation options, the requested format (email, numbers) and so on.

In Switzerland not everyone has a telephone connection anymore but a mobile number. So, I want to ensure that one of both fields has been filed out the phone number or the mobile number.

So, if I set both to required, I have to explain in the text that he should copy his phone number into both fields or the form won’t pass the validation.

So is there a possibility to validate that one of both fields has information in there and if yes to save the information to the database and if not that the user gets a message that one of both numbers have to be filled in.

Regards

Hi,

You can bind the required validation on client side using dmx. dmx-bind:required="!otherNumber.value"

On server side you will have to use the conditional step to check which of the two got submitted.

Hi,
Thanks, i will try today.

Hi

I think I’m doing something wrong:

I have still activated the required options on both fields. I have added (first one the one and then on both fields the !inp_xxx.value option). But both fields are still required and complaining when fill out only one of them.

I attach my code perhaps you’ll see if I really have done what you have recommended to me to do.

Thanks

Telefon

<input type=“tel” class=“form-control form-control-sm” id=“inp_Telefonnummermain” name=“Telefonnummermain” aria-describedby=“inp_Telefonnummermain_help” placeholder=“Ihre Telefonnummer oder Ihre Natelnummer”

required="!inp_Natellnummermain.value" data-msg-required=“Geben Sie bitte Ihre Telefonnummer oder die Handy-Nummer ein!” autocomplete=“off”>

Natel

<input type=“tel” class=“form-control form-control-sm” id=“inp_Natellnummermain” name=“Natellnummermain” aria-describedby=“inp_Natellnummermain_help” placeholder=“nochmals Ihre Natelnummer”

required="!inp_Telefonnummermain.value" data-msg-required=“Geben Sie bitte Ihre Telefonnummer oder die Handy-Nummer ein!” autocomplete=“off”>

Hi. Please remember to put your code between three backticks - ```

The html shows only required attribute. You need to make it dynamic. Please see my code above again.

Thanks

Now it works - thanks for the information to do-it dynamic, i have finally found.

Regards

1 Like