-1

My html is:

 <input type="text" name="username">

If we write any validation also ,i need the function related stuff to happen in typescript but not java script.

shinchan
  • 35
  • 1
  • 1
  • 10

1 Answers1

1

The simplest way is to use Regex in whatever implementation you need to filter for leading/trailing whitespace. If you want simple validation, try the HTML5 pattern attribute.

^(?=[A-Za-z0-9])([A-Za-z0-9\s]*)(?<=[A-Za-z0-9])$

https://regex101.com/r/bJCJBv/2

pablow
  • 66
  • 3