› Forums › Dynamic Forms for SharePoint › Fixed value for Form Field
- This topic has 4 replies, 2 voices, and was last updated 1 year, 7 months ago by
B.Sanchez.
-
AuthorPosts
-
-
July 29, 2019 at 21:55 #26363
B.Sanchez
ParticipantI have three fields I need to displace as no more 4 decimal places in the form. The field names are CurrentResult1moprior, CurrentResult2moprior and CurrentResult3moprior This are text fields due to Cascading Dropdowns so I assume I have to first convert to number. I’m trying may code snippets found on this forum but none have helped. Here is the last one used:
function convertresult(){ var Result2mo = getFieldValue("CurrentResult2moprior"); if(!isNaN(Result2mo)){ var resultValueFixed = Number(Result2mo).toFixed(4); setFieldValue("CurrentResult2moprior",resultValueFixed); } }
Attachments:
-
July 30, 2019 at 08:05 #26383
Alexander Bautz
KeymasterI’m not sure I understand exactly, but if you want to ensure the user types in the correct format you can use something like this:
jQuery("#dffs_CurrentResult2moprior input").on("blur",function(e){ var str = jQuery(this).val().replace(/[^0-9.]/g, ''); jQuery(this).val(Number(str).toFixed(4)); });
Alexander
-
July 30, 2019 at 15:04 #26400
B.Sanchez
ParticipantOMGeee that is not what I was looking for by I am floored. Wow!!! thank you! I have added this to the form as it will be VERY handy. My original question was for a field that will already have read-only data already pre-populated for them using cascade dropdowns. I just need that pre-populated result to not be longer than 4 decimal places at most.
-
July 30, 2019 at 15:30 #26404
Alexander Bautz
KeymasterI see. There is no built in function for manipulating the values in a cascading dropdown – if you use a number column it will by default show 10 decimal because it this this way it is stored in the DB.
I think the easiest would be to create calculated columns in the source list to set the correct format of the field there – and then use the calculated fields in your cascading dropdown config.
Alexander
-
July 30, 2019 at 15:49 #26407
B.Sanchez
ParticipantI will do that. Thanks again Alexander!
-
-
AuthorPosts
- You must be logged in to reply to this topic.