Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142188

Remove characters from a string that are not firstname/surname characters

$
0
0

Please see the code below:

 @HostListener('paste', ['$event'])
  onPaste(event) {
    var test = event.clipboardData.getData('text');
    var removedNumbers = test.replace(/[0-9]/g, '');
  }

Numbers are removed from the pasted text. It is a surname field, so should also exclude characters like {[}] etc.

How can I remove characters that are not valid for a name? I have read lots of simlar questions today like this one: how do i block or restrict special characters from input fields with jquery?. However, I have not found an answer to my specific question.


Viewing all articles
Browse latest Browse all 142188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>