How to set number validation with commas and decimal

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
ramanjjilunaidu
Posts: 22
Joined: Tue Sep 05, 2017

22 Sep 2017

Hi All,
I have "number" columns in my spforms form, i want to restrict the number upto one decimal and put commas every three digits like 1,231,789.9
Any suggestions please

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

25 Sep 2017

Hello!
You can try a number formatting plug-in. For instance, this one:
https://github.com/customd/jquery-number
Cheers

ramanjjilunaidu
Posts: 22
Joined: Tue Sep 05, 2017

26 Sep 2017

Hi Nikita,
I didn't understand anything over there, there are many files as well. Would you please help me.
Thanks
Ram

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

27 Sep 2017

Alright, there is nothing complicated, you just need to take these steps:
1) Go to GitHub page and download this plugin as zip file. On the page you can see green button that says Clone or Download, click it and select Download Zip:
1 - Download.png
1 - Download.png (46.3 KiB) Viewed 1749 times
2) You will download Zip archieve. You will need to unpack it and get the folder inside of it:
2 - Folder.png
2 - Folder.png (2.98 KiB) Viewed 1749 times
3) Now you need to upload this folder online, so you can get access to it on your Forms. I've uploaded mine to the default Documents folder on my site, you can do the same:
3 - Upload.png
3 - Upload.png (10.31 KiB) Viewed 1749 times
4) Next, on my Form, I gave CSS Class "number" to the fields I wanted to format:
4 - CSS Class.png
4 - CSS Class.png (5.88 KiB) Viewed 1749 times
5) Finally, I've added JavaScript to link uploaded files to the Form and format fields with class "number":

Code: Select all

//set jQuery to global scale, so uploaded files can use it
window.$ = $;
window.jQuery = $;

//import uploaded files to the page
var imported = document.createElement('script');
//don't forget to change site url to your site name, shared documents is the default name of "Documents" folder
imported.src = '/sites/mysite/shared documents/jquery-number-master/jquery.number.js';
document.head.appendChild(imported);

//need a little time to load js file
setTimeout(function(){
	$( ".number" ).find( "input" ).number( true, 1 );
}, 500);
And here is the result:
5 - Result.png
5 - Result.png (1.69 KiB) Viewed 1749 times
Follow the steps closely and you'll be able to reproduce it.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests