Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q709 How can I remove invalid characters from a form field before submission?

You are here: irt.org | FAQ | JavaScript | Text | Q709 [ previous next ]

Try:

<SCRIPT LANGUAGE="JavaScript"><!--
function validated(string) {
    for (var i=0, output='', valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
}
//--></SCRIPT>

<FORM>
<INPUT TYPE="TEXT" onChange="this.value=validated(this.value)">
</FORM>

Feedback on 'Q709 How can I remove invalid characters from a form field before submission?'

©2018 Martin Webb