Page 1 of 1

Validation (not in a form)

Posted: Tue Nov 26, 2019 6:47 pm
by Starb7
Hi Pablo

Created a site just a bit of fun for a friend to calculate running costs (must be loads of them) and it works fine, https://www.supake.co.uk/arc/Index.html apart from Validation.

I cannot get it to perform a validation check, eg Watts should have a value from 1 to 10000 but you can enter 0 and it does not 'check' - where am I going wrong?

TIA

Re: Validation (not in a form)

Posted: Tue Nov 26, 2019 7:22 pm
by Pablo
Validation only works with forms.

Note that I cannot help you wit custom code.

Re: Validation (not in a form)

Posted: Tue Nov 26, 2019 9:29 pm
by Starb7
So if I enable form it will work? It didn't :( but why?

Re: Validation (not in a form)

Posted: Tue Nov 26, 2019 11:06 pm
by Starb7
I have created a simple 1 field in a cell grid, no form and Form not enabled and that does validate as expected.

Q. Why does a new one field test work with no form but a multiple field one doesn't?

You say it only works in forms but it appears that's not the case?

Cheers

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 7:05 am
by Pablo
Please remove all custom code and then try again.

Tip: start with a simply form and make sure that works form, then add other elements.
With so many elements on the pate it is difficult me to make any sense form it without having the project.

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 10:00 am
by Starb7
Hi Pablo

I have uploaded this https://www.supake.co.uk/arc/formtest.html and the page does validate whether it's a form or not.

I have seen your response but you said earlier that only forms validate, was that incorrect? Not much point me stripping it down if that is the case (as proven above) especially if you remove that functionality in a later version.

Can you confirm that field validation DOES work whether it's a form or not?

Cheers

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 10:37 am
by Pablo
I have uploaded this https://www.supake.co.uk/arc/formtest.html and the page does validate whether it's a form or not.
The elements are part of a form (layout grid).
I have seen your response but you said earlier that only forms validate, was that incorrect?
No, it was not incorrect, a layout grid is also a form.

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 10:56 am
by Starb7
Hi Pablo

Yes, but this layout grid is not set as a form, so I checked it all based against your comment suggesting it wasn't working because it was not a form. In this case then, it was a form (despite not being set as one) so that threw me off any other checks.

I have actually now found this issue and it's nothing to do with being a form (enabled or not in a grid) and it's because the validation 'Error message:' contained an apostrophe, ie it was "What's your daily Energy Unit Cost in pence? eg 15" and is now "What is your daily Energy Unit Cost in pence? eg 15"

Do not this is not the same issue as https://www.wysiwygwebbuilder.com/forum ... 10&t=64868 as you can have brackets and ? characters, it only appears to be ' that upset it. Perhaps this is a bug?

Thanks for you help once again.

Cheers

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 11:01 am
by Pablo
Yes, but this layout grid is not set as a form, so I checked it all based against your comment suggesting it wasn't working because it was not a form.
Still it's a form (container).
I have actually now found this issue and it's nothing to do with being a form (enabled or not in a grid) and it's because the validation 'Error message:' contained an apostrophe, ie it was "What's your daily Energy Unit Cost in pence? eg 15" and is now "What is your daily Energy Unit Cost in pence? eg 15"
In HTML/javascript, apostrophes and quotes should be escaped with \
What\'s your daily Energy Unit Cost in pence? eg 15

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 11:19 am
by Starb7
Thanks, I didn't realise you have to do it in the editor, I presumed the editor did that when it compiled the project, etc. All noted and thanks again.

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 6:39 pm
by Starb7
Hmm, odd thing is that if you put
What\'s your daily Energy Unit Cost in pence? eg 15
you actually get
What\'s your daily Energy Unit Cost in pence? eg 15
, ie the ' is now shown but so is the \

Apparently, the 'proper' way for HTML is to quote it using
'
ie the line becomes
What's your daily Energy Unit Cost in whole pence? eg 15
and this works as expected. :)

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 6:42 pm
by Starb7
In a related issue with Validation, I want to validate a number and that works OK for whole numbers but how do I validate a decimal, eg 12.34? The validation no longer works and thinks there's an error, ie not a number. TIA

Re: Validation (not in a form)

Posted: Wed Nov 27, 2019 7:04 pm
by Pablo
I'm sorry, there is no standard option for numbers with decimals.
But you can create custom regular expressions.

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 12:16 am
by Starb7
Okidoke, cheers

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 4:52 pm
by Starb7
Pablo wrote: Wed Nov 27, 2019 7:04 pm I'm sorry, there is no standard option for numbers with decimals.
But you can create custom regular expressions.
Hi Pablo and anyone else who can help?

Having problems creating a regular expression to validate a number only from 0 to 99 allowing 2 decimal places that works. I have got it down to ^[0-9]+(.[0-9]{1,2})?$ but that doesn't seem to work so wonder if there's an issue with Custom Validations?

There is also an oddity that may be browser based or is a bug in WWB? If you create a very simple page that has one field in it, placed in a form (Layout Grid) and set it to be a Number, eg https://www.supake.co.uk/arc/validate.html if you test the validation in Edge the field type is ignored, ie you can type text as well as numbers but if you test it in Chrome then it works except for the character e Now, I expect that's because a number can have an e (Euler's/Exponent) in it, but I can't use any other mathematical constants like i or K, etc, so suspect the e should not be allowed too. Q. Why would Edge, IE11, Safari let any text but Chrome not?

Any guidance on the RegEx appreciated.

Cheers

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 5:52 pm
by Pablo
I'm sorry, I cannot help you with regular expressions.
However, this is standard HTML functionality. So, you can find lot of information about this on the Internet.

WWB dos not modify the behavior of regular expressions, so if it does not work then there is most likely a mistake in your settings.

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 6:21 pm
by Starb7
Okidoke, any thoughts on the validation issues between browsers?

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 6:29 pm
by Pablo
It should work the same in all browsers but this is unrelated to WWB.
Regular expressions are implemented in the browser not in WWB, the expression will be published "AS IS".

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 6:56 pm
by Starb7
Please re-read post, nothing to do with reg expressions. This is another issue using basic validation. Cheers

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 7:29 pm
by Pablo
HTML5 validation is standard HTML functionality. It is implemented in the browser.

Please see known limitations:
https://caniuse.com/#feat=input-number

Re: Validation (not in a form)

Posted: Thu Nov 28, 2019 9:37 pm
by Starb7
Thanks for the info. Cheers