I have the following to disallow spaces
function nospaces(t){
if(t.value.match(/\s/g)){
alert('Username Cannot Have Spaces or Full Stops');
t.value=t.value.replace(/\s/g,'');
}
}
HTML
<input type="text" name="username" value="" onkeyup="nospaces(this)"/>
It works well for spaces but how can I also disallow full stops as well?
Below is the sample html and javscript you just wanted to add /./g for checking for .
If not its not necessary to use regex you can use
or if required
Try this