Validation error for 0 in numeric field
-
Hi,
In the registration form, I’ve put a numeric field with:
– no default value
– min value: 0
– max value: 7
– validation: numeric value only
The intent is to allow 0, 1, 2, 3, 4, 5, 6 or 7.When the user fills in the form, a validation error is thrown when the user inputs the value 0.
Any clue would be helpful.
Regards
-
I tried but can’t reproduce you validation error for the selection of a 0.
What exact error message do you get?
What happens if you don’t use the “Numeric value only” validation and use “None” for validation?
The default “Number” setup field with min and max values is already restricted to default numbers and “Numeric value only” validation might be more relevant for numbers in text fields.
Thanks a lot for your answer @missveronicatv.
It just says “<field_label> is mandatory”:
– if no choice has yet been done
– when selecting 0 with the arrow or typing itI removed the “Numeric value only” validation but got the same message.
If I uncheck “Mandatory”, the min value 0 is put in the field.
If I put a min value of 1 (and keep field mandatory), the min value of 1 passes validation.
I can’t find the text string “is mandatory” or “Mandatory” anywhere in the core UM sources.
Which English translation are you using and which version of UM?
I can read from your Post history that you are comparing two membership plugins.
Can you deactivate the other membership plugin for your UM tests.Indeed I tested other plugins but finally kept only UM. All others are deactivated and uninstalled.
Sorry if the translation is not accurate, I’m working with WordPress in French.
A copy of the settings of this numeric field can be seen there: https://imgur.com/c1DFuvl
It can be temporarily tested there: https://global.toutchat-toutmoi.com/register/
Just click on the button at the bottom and you’ll see all validation errors, incl. the “Nombre” field (near the bottom of the page).Can you turn off ModSecurity in cPanel.
Yes, done
It seems like a conflict with another plugin or your theme.
Follow these steps for a conflict test:
https://docs.ultimatemember.com/article/96-how-to-do-a-plugin-theme-conflict-test
I switched to theme Twenty fifteen and kept only 1 plugin: UM.
The problem still occurs.
You have four additional submit buttons on the page:
Search Search Refuser AccepterCan you remove them for a test of the Registration form.
Hi @dgoethals
..This thread has been inactive for a while so weβre going to go ahead and mark it Resolved…
..Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and weβd be happy to help… π
Regards,
Hi,
I’ve installed the latest version (5.8.2) of a French WordPress on a local machine.
Theme: Twenty fifteen – Search Widget removed (the only submit button on the page is the UM one)
1 extension active: UM
I’ve added a numeric field to the default UM registration form:
– mandatory
– max value 100
– min value: left empty
– validation: none
I can choose -2, -1, 1, 2… But if I choose 0, I got the message telling me that this field is mandatory.I’ve added a text box to the same form:
– mandatory
– min. length: 0
– max. length: 3
– validation: numeric value only
I can type any numeric value: -1, 0, 1…
It may seems to be OK, but this number should represent a number of children (negative values excluded thus) and I want to be sure that the user did not forget to indicate the value and did not use a default one.
Any clue on how to achieve this?Your help is more than welcome. Thanks
What is the operating system at your web hosting?
I have made a code snippet based on your explanation of this issue with the number 0.
First:
Install the code snippet by adding to your child-theme functions.php file or use the “Code Snippets” plugin.
Change my test meta_key name from ‘my_um_number’ to your meta_key name.
Change the error message from ‘Error message’ to your message.Second:
Modify your number field in UM Forms designer to use the code snippet for validation:
– select “Custom Validation”
– enter “number_zero_seven” in the “Custom Action” field.Reference:
https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-fieldadd_action('um_submit_form_errors_hook_','um_custom_validate_number_zero_seven', 999, 1); function um_custom_validate_number_zero_seven( $args ) { $meta_key = 'my_um_number'; if ( !empty( $args[$meta_key] )) { $number = intval( trim( $args[$meta_key] )); if( $number === false || $number < 0 || $number > 7 ) { UM()->form()->add_error( $meta_key, 'Error message' ); } } }-
This reply was modified 4 years, 4 months ago by
missveronica.
-
This reply was modified 4 years, 4 months ago by
missveronica.
Thanks a lot @missveronicatv. It works perfectly.
Thanks for letting us know how it resolves the issue.
Regards,
-
This reply was modified 4 years, 4 months ago by
The topic ‘Validation error for 0 in numeric field’ is closed to new replies.