Reputation: 9
How to remove special character but not the SPACE
I got the Javascript and its working fine..i just can't figure it out how to ignore SPACE correction
<script type="text/JavaScript">
function valid(f) {
!(/^[A-zÑñ0-9]*$/i).test(f.value)?f.value = f.value.replace(/[^A-zÑñ0-9]/ig,''):null;
}
</script>
Upvotes: 0
Views: 169
Reputation: 14927
Should be
!(/^[A-zÑñ0-9 ]*$/i).test(f.value)?f.value = f.value.replace(/[^A-zÑñ0-9 ]/ig,''):null;
Upvotes: 1