Changes

Removing Special Characters

311 bytes added, 16:52, 24 April 2009
no edit summary
==Procedure:==
1. Include the following code in the HTML Tag box of the [[Custom Fields|custom field]] you wish to restrict:
onchange="javascript:this.value=this.value.replace(/['''''character set''''']/g,' '''replacement character''' ');"
==Examples==
'''1. To remove all & ~ ! @ # $ % ^ & * ( ) + " and ' characters and replace them with an underscore (_) actively while typing the text.
<pre>
onkeyup="javascript:this.value=this.value.replace(/[\W]/g,'_');"
</pre>
The example above '''2. After user has entered text and clicked away from the field, the following code will remove all & ~ ! @ # $ % ^ & * ( ) + look for " and ' characters quotes and replace them with an underscore (_). If you would rather simple remove <pre>onchange="javascript:this.value=this.value.replace(/['\''&'\"']/g,'_');"</pre> '''3. To restrict user to only enter Integer numbers write this code in the characters you should use the following as the last line of the functionHTML tag box.<pre>onkeyup="javascript:this.value=this.value.replace(/[^\d]/g,'');" </pre>
[[Category:Custom Fields]][[Category:JavaScript Examples]]
Smartstaff
137
edits