Jump to content

Remove Special Characters


Recommended Posts

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>

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 years later...
  • 1 year later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...