jrodriguez88 Posted October 17, 2017 Report Share Posted October 17, 2017 I have a couple of field which allow users to put phone numbers, employee numbers and etc. However, Employees will always find ways to put special characters. I will need a JS to remove all special characters from these fields. Please help. Quote Link to comment Share on other sites More sharing options...
FlashD Posted October 17, 2017 Report Share Posted October 17, 2017 Hi jrodriguez88, You can refer: https://stackoverflow.com/questions/469357/html-text-input-allows-only-numeric-input Also please refer below post for handling the id and class names. Always add the JavaScript code in your header and also include jQuery library in it. Quote Link to comment Share on other sites More sharing options...
jrodriguez88 Posted October 18, 2017 Author Report Share Posted October 18, 2017 Ok. I have an update form and I will need to create a function that will execute on update similar to the one below and will need it to check for characters outside the a-z and A-Z and delete them. Any idea? window.onload = function () { var passwordField = document.getElementById('EditRecordPASSWORD'); var confirmationField = document.getElementById('EditRecordPASSWORD@Confirm'); passwordField.value = ''; confirmationField.value = ''; }; </script> Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted October 18, 2017 Report Share Posted October 18, 2017 Hi jrodriguez88, You can use the following snippet of code to remove special characters from a user input: <script> function check() { var x = document.getElementById("EditRecordYOUR_FIELD").value; document.getElementById("EditRecordYOUR_FIELD ").value=x.replace(/[^a-zA-Z ]/g, ""); } document.getElementById("caspioform").onsubmit = check; </script> Please place this code into the Footer of your Details Datapage. Quote Link to comment Share on other sites More sharing options...
jrodriguez88 Posted October 20, 2017 Author Report Share Posted October 20, 2017 Thanks! It works using one field but I have multiple. I have tried this but it does not strip special characters when I am trying to use it for multiple fields. Any advice. <script> function check() { var x = document.getElementById("EditRecordPHONE_NUMBER").value; document.getElementById("EditRecordPHONE_NUMBER").value=x.replace(/[^0-9 ]/g, ""); } document.getElementById("caspioform").onsubmit = check; function checkB() { var y = document.getElementById("EditRecordMOBILE_NUMBER").value; document.getElementById("EditRecordMOBILE_NUMBER").value=z.replace(/[^0-9 ]/g, ""); } document.getElementById("caspioform").onsubmit = check; </script> Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted October 20, 2017 Report Share Posted October 20, 2017 Hi jrodriguez88, I would suggest combining your functions within a single function. Here is a code: <script> function check() { var x = document.getElementById("EditRecordPHONE_NUMBER").value; var y = document.getElementById("EditRecordMOBILE_NUMBER").value; document.getElementById("EditRecordPHONE_NUMBER").value=x.replace(/[^0-9 ]/g, ""); document.getElementById("EditRecordMOBILE_NUMBER").value=z.replace(/[^0-9 ]/g, ""); } document.getElementById("caspioform").onsubmit = check; </script> Hope this helps. Quote Link to comment Share on other sites More sharing options...
GoodBoy Posted May 31, 2021 Report Share Posted May 31, 2021 Hi everyone! Just to share, there is an online article related to this: https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/remove-special-characters-for-input-fields/ Quote Link to comment Share on other sites More sharing options...
futurist Posted June 1, 2022 Report Share Posted June 1, 2022 Hi all, sharing this one which might be of help to you: Quote Link to comment Share on other sites More sharing options...
Kurumi Posted February 29 Report Share Posted February 29 Hi! Just wanted to share this solution if you want to read or accept the single quote or apostrophe (') in the formula: https://stackoverflow.com/questions/9596652/how-to-escape-apostrophe-a-single-quote-in-mysql Example: Replace([@field:FIELDNAME], 'Can''t found the name', 'Remove name') 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.