This script is making all of my text larger. Anyone know why?

Code:
<script type="text/javascript">
function nospaces(t){
if(t.value.match(/\s/g)){
$error_msg="Sorry, you are not allowed to enter any spaces";
t.value=t.value.replace(/\s/g,'');
}
}
</script>