Home › Forums › General discussion › Number field validation to use dot and not comma
Tagged: decimal comma, Decimal dot
- This topic has 6 replies, 3 voices, and was last updated 4 years, 10 months ago by Steve.
-
AuthorPosts
-
-
March 3, 2019 at 02:48 #24048
Hi all,
Is there a way to decline an entry in a number field with commas and to tell the user to use a full stop instead?
SharePoint converts “14,5” to “145” and I need users to enter “14.5”.
Many thanks.
-
March 3, 2019 at 22:25 #24050
I got it sorted via column validation using the following formula:
=ISNUMBER(VALUE(TRIM(CLEAN([Column Name]))))
but the column needs to be in a Text format, not a number format. I then use Flow to convert it back to a proper number.
I wonder if there’s a way of using DFFS. No worries if not.
-
March 4, 2019 at 19:02 #24073
Hi,
Add something like this to your Custom JS to replace “,” with “.”:jQuery("#dffs_YOUR_FIELDINTERNALNAME input").on("keyup",function(e){ var str = jQuery(this).val(); jQuery(this).val(str.replace(",",".")); });
Change “YOUR_FIELDINTERNALNAME” with your field internal name.
Alexander
-
February 17, 2020 at 07:53 #28716
Thank you, Alex, it helped me a lot.
In Czech, we have comma separator instead of a decimal dot.
And I changed the event from “keyup” to “change” and it works perfectly.
Steo
-
-
May 4, 2019 at 01:12 #25193
Thanks Alexander.
Unfortunately, this is a text field and users can enter anything in there. Is there a way to replace any other character than a number with ‘no space’?
I have a Flow built for this form and I’d like to avoid redoing the Flow, if possible.
-
May 4, 2019 at 12:08 #25197
Ok, I found a way to do this. Actually, a few ways, but which one is more appropriate or correct or are all of them correct?
jQuery("#dffs_Title input").on("keyup",function(e){ var str = jQuery(this).val(); jQuery(this).val(str.replace(/[^0-9.]/g, '')); });
or
jQuery("#dffs_Title input").on("keyup",function(e){ var str = jQuery(this).val(); jQuery(this).val(str.replace(/[^\d.-]/g, '')); });
both work and do what I need them to do, but what’s the difference?
-
May 6, 2019 at 18:26 #25215
The two are basically the same – the \d metacharacter is used to find a digit from 0-9.: https://www.w3schools.com/jsref/jsref_regexp_digit.asp
This means you can use the one you find easiest to read / understand.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.