Reputation: 490
How to make an input field to type only a non-whitespaces word of size 40 characters? suggest any directive or any other solution?
Valid input text: "Lorem ipsum dolor sit amet, justo explicari honestatis"
inValid input text: "Lorem ipsum dolor sit amet, Loremipsum LoremLoremLoremLoremLoremLoremLoremLoremLorem justo"
invalid input contains a word with size 45 characters without any space
i.e: "LoremLoremLoremLoremLoremLoremLoremLoremLorem"
Upvotes: 0
Views: 58
Reputation: 6448
You could register a changelistener
on the input field and analyze the entire input every time the user typed something. Subtract the number of whitespaces from the length of the input field value and if the result exceeds 40 characters, delete the last character of the input and notify the user.
Upvotes: 1