Vitalikssssss Posted September 6, 2018 Report Share Posted September 6, 2018 Hi there! Does anyone have a JS/Jquery solution to restrict the user to be able to enter only time value in a field (Text255)? I have a Tabular Report datapage with inline edit enabled. Thanks, vitalikssssss Quote Link to comment Share on other sites More sharing options...
vinebath Posted September 7, 2018 Report Share Posted September 7, 2018 Hey Vitalikssssss, You can try using this code in the footer of the page: <script> window.onload = function () { document.getElementById('InlineAddFieldname').addEventListener('input', function (w_e) { //here instead of Fieldname insert the name of the field that should be masked if (!isNaN(w_e.data) && w_e.data !== ' ') { if (this.value.length >= 2 && !this.value.includes(':')) { this.value = this.value.slice(0, 2) > 23 ? 23 : this.value.slice(0, 2) + ':' + this.value.slice(2, 3); } if (this.value.length == 3 && this.value.includes(':')) if (!this.value.includes('0')) this.value = parseInt(this.value); else this.value = this.value.slice(0, 2); if (this.value.length > 3) this.value = this.value.slice(0, 2) + ':' + (this.value.slice(3, 5) > 59 ? 59 : this.value.slice(3, 5)); prevVal = this.value; } else this.value = prevVal; }) }; </script> This code however does not process manual pasting of values. If needed, I can try and think of something to avoid this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.