durangod
09-25-2012, 03:39 PM
Hi i been playen around with some javascript to try to do some extra validation to my form.
Issue: someone was too lazy to type anything in the textarea so they just
typed in
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''hello
to reach their 120 char min requirement.
what i came up with is not that great so i thought i would ask here.
Here is what i have
function chk_validchars()
{
var field=document.getElementById("mytext").innerHTML;
var newfield=str.replace("''''''''''","invalid character");
document.getElementById("mytext").innerHTML=newfield;
}
</script>
Here is the out put (certainly not what i want) I thought maybe it would at least put invalid character on every occurance of the length of ' but it just does it once.
invalid character''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''hello
Prefered would be either replace with null or even something like this
'''''''i am an Idiot''''''i am an idiot'''''''''''''''''''''''''hello
lol sorry just had to be mean on that one, but seriously if we could replace multiple chars of 4 or more like '''''' or ............. with some kind of text like invalid would be great.
120 chars required is only three lines of short text and hard to believe people cant come up with that.
Issue: someone was too lazy to type anything in the textarea so they just
typed in
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''hello
to reach their 120 char min requirement.
what i came up with is not that great so i thought i would ask here.
Here is what i have
function chk_validchars()
{
var field=document.getElementById("mytext").innerHTML;
var newfield=str.replace("''''''''''","invalid character");
document.getElementById("mytext").innerHTML=newfield;
}
</script>
Here is the out put (certainly not what i want) I thought maybe it would at least put invalid character on every occurance of the length of ' but it just does it once.
invalid character''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''hello
Prefered would be either replace with null or even something like this
'''''''i am an Idiot''''''i am an idiot'''''''''''''''''''''''''hello
lol sorry just had to be mean on that one, but seriously if we could replace multiple chars of 4 or more like '''''' or ............. with some kind of text like invalid would be great.
120 chars required is only three lines of short text and hard to believe people cant come up with that.