Yeah i have to apply pattern.Correct.But what if I have to apply to say many text fields that too in different page .Is there a way to apply a pattern to all the text fields once at a time?
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.
<input required pattern=".*\S+.*" title="This field is required">