Shubhanker
Shubhanker

Reputation: 9

How to remove special character but not the SPACE

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&#209;&#241;0-9]*$/i).test(f.value)?f.value = f.value.replace(/[^A-z&#209;&#241;0-9]/ig,''):null;
} 
</script>

Upvotes: 0

Views: 169

Answers (1)

ic3b3rg
ic3b3rg

Reputation: 14927

Should be

!(/^[A-z&#209;&#241;0-9 ]*$/i).test(f.value)?f.value = f.value.replace(/[^A-z&#209;&#241;0-9 ]/ig,''):null;

Upvotes: 1

Related Questions