Invalid Character Filter

[Total: 0    Average: 0/5]

Looks for the Invalid characters and Gives a User friendly Message if a Invalid Character is found.

Head Code:

<Script>
function isLegal(txt) {
var invalids = "!@#$%^&*()-~,'<.>/?;:|"
for(i=0; i<invalids.length; i++) {
if(txt.indexOf(invalids.charAt(i)) >= 0 ) {
return false;
}
        }
return true;
}
</Script>

Body Code:

<Script>

name1 = "I am the Game and I am that Damn Good"



if(isLegal(name1)) {

document.write("Thank You")

}

else {

document.write("Not Valid String")

}

</Script>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *