Removing Special Characters for Input Fields
1 minute to readIn this article, we will guide you on how to remove unwanted special characters from input fields in submission forms.
Steps:
- Edit your Submission Form DataPage.
- Add a Header and Footer in the Configure Fields screen of the DataPage wizard.
- Disable the HTML Editor in the Footer section.
- Copy and paste the following JavaScript in the Footer.
<script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function(event) { var x = document.getElementById("InsertRecordFIELDNAME").value; document.getElementById("InsertRecordFIELDNAME").value=x.replace(/[^a-zA-Z0-9 ]/g, ""); }); </script>
- Replace the FIELDNAME in the JavaScript with the name of the field. For example, if the name of the field is First_Name, then it should be InsertRecordFirst_Name.
- Save the DataPage.
Note: You can apply the JavaScript to a Single Record Update Form by following the above steps and changing instances of InsertRecord to EditRecord.
Note: This article uses external HTML, JavaScript, or third-party solutions to add functionality outside of Caspio standard feature set. These solutions are provided “as is” without warranty, support or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.
For assistance with further customization based on your specific application requirements, please contact our Professional Services team.