URL Validation requires https://
-
URL Validation in Hustle requires “https://” prefix – forminator URL validator does not require this.
I think it’s better to not require https:// as many people are not even aware of that prefix anymore because most browsers hide it by default.
Is this something that might change or can we have an option to have the same validator being used in Forminator instead?
-
I hope you are doing well today.
Thank you for those details. I will bring this to our Forminator and Hustle Team’s attention and see which road to choose and I will mention your suggestion. As a temporary solution, you can place a Forminator form in a popup which will help you skip that HTTP validation.
Kind Regards,
KrisI hope you’re well today!
Our developers already have a task for future to update the validation in Forminator so it will be “unified” (though I don’t have ETA).
For now, you can use this code as a workaround to make validation in Forminator the same as it is in Hustle:
<?php add_filter( 'forminator_field_website_validation_rules', 'wpmudev_validate_website_url', 10, 3 ); function wpmudev_validate_website_url( $rules, $id, $field ) { if ( false !== strpos( $rules, 'validurl' ) ) { $rules = str_replace( '"url": false,', '', $rules ); } return $rules; }
To add it to site:
– create an empty file with a .php extension (e.g. “formiantor-url-prefix-validation.php”) in the /wp-content/mu-plugins folder of your site’s WordPress install
– copy above code and paste it into that file
– save the file.
It should then work out of the box.
Best regards,
AdamSince we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to open a new thread if you have new queries.
Kind Regards
NithinHello,
Sorry for the late reply!
Thank you for the suggestion and the code!
However, I think it’s better to not require the “https://” prefix. Is it possible to do that?
Look forward to hearing from you.
Sebastian
Thank you for response but I’m a bit confused now.
You already can simply disable validation in field settings. If you set validation to “none” it will not check for protocol prefix.
Or do you mean to have some sort of validation there but in a way that will only skip prefix (like: if it’s there, it’s fine, if it’s not there it’s fine too, provided that the rest of the string appears to be an URL)?
Kind regards,
AdamHello,
Thanks for your reply.
I think you got it in your last paragraph, pasted below.
Or do you mean to have some sort of validation there but in a way that will only skip prefix (like: if it’s there, it’s fine, if it’s not there it’s fine too, provided that the rest of the string appears to be an URL)?
Let me break it down again just to make sure we understand each other ??
Forminator URL validation will allow BOTH: “example.com” and “https://example.com”
Hustle URL validation will allow ONLY: “https://example.com”
I think the forminator validation is better because most people forget about https://
Best,
Sebastian
Thank you for response and confirmation, all seems clear now.
We’ll need to consult that with our developers so I’ve already asked them and we’ll update you here once we got feedback.
I’d appreciate some patience, though. They are dealing with a lot of complex tasks on daily basis so it may take a bit longer to get response. But we’ll update you here right away once we get it.
Best regards,
AdamI just got response from our developers and they provided another piece of code that should do the trick. With the code validation in Hustle should work like this:
example.com VALID https://example.com VALID https://example.com VALID [email protected] NOT VALID
You’ll find the code here:
https://gist.github.com/wpmudev-sls/c96c180266795197c7ee3344b875b712
Please add it to your site as a Must Use plugin (same way as you added previous one) and then make sure that in URL field settings in Hustle validation is disabled – this is important; it has to be disabled in plugin so this code would take over.
It should do the job then.
Kind regards,
AdamHello,
Thank you! Although that is letting anything through. I can just type in “example” and it is allowed. Can you please check with the developers if there was a mistake?
Best,
Sebastian
I could replicate this issue and will bring attention to our developers, we will keep you posted.
Best Regards
Patrick FreitasAn update here, the script is using filter_var function with the FILTER_VALIDATE_URL, it will validate the example as a valid URL hence you can have “localhost” or just configure your local computer to point to any string like https://example
Best Regards
Patrick FreitasHi,
Sorry I’m not familiar with the PHP language and I don’t understand the last statement.
I thought we were aiming for validation that was intuitive for the user and prevents recieving junk data like below:
example.com VALID
https://example.com VALID
https://example.com VALID
[email protected] NOT VALID
example NOT VALID
https://example NOT VALIDPlease can you break down what you mean with the statement below?
…it will validate the example as a valid URL hence you can have “localhost” or just configure your local computer to point to any string like?https://example
Please can you break down what you mean with the statement below?
…it will validate the example as a valid URL hence you can have “localhost” or just configure your local computer to point to any string like https://example
The script that we shared is using core PHP “tool” to validate URL. PHP takes into account that the site may be installed under so called “local domain name”. Basically, it’s a non-public domain used e.g. when you develop the site using local webserver on your local computer instead of some hosting/server “on the internet”.
Such domain can be anything, like “https://example”, “https://localhost”, “https://something.dev” and so on -that’s solely up to your local webserver configuration but it’s a perfectly valid domain. That’s why it is validated by PHP out of the box.
I thought we were aiming for validation that was intuitive for the user and prevents recieving junk data like below:
Yes, we were but our developers used that PHP function as it’s simply compliant with the RFC 2396 standard.
But I’ve asked them already to adjust that to follow your example validation exactly. We’ll update you here again soon.
Kind regards,
AdamOur developers updated the code so now it validates as listed below.
YES:
example.com
https://example.com
https://example.com
https://www.example.com
https://www.example.com
https://www.example.comNO:
[email protected]
example
https://example
https://example
https://www.example
https://www.example
https://www.exampleYou’ll find updated code at the same URL here
https://gist.github.com/wpmudev-sls/c96c180266795197c7ee3344b875b712
so you just need to replace the code you already have with this new version.
Best regards,
AdamThat’s awesome, thanks so much!
I just installed and tested and seems to be working fine.
Thanks again!
Sebastian
- You must be logged in to reply to this topic.