I want to control form of user input in textarea on my page. The input has to look exactly like this:
That means only three values in one row and semicolon between the first and the second and between the second and the third value.
By now I am using this regex to validate it:
^((([^;]+);([^;]*);([^;]+))\n?)*$
It does not work 100%, because it validates input like
value1;value2;value3
value1
as valid. Problem is the new line and the beginning of next value1. It seems like until first semicolon written after the value1, the value1 is still appended to the end of the value3 in previous line. How should I change the regex to disable this and mark every new incomplete line as invalid?
I created an JS fiddle to demonstrate: https://jsfiddle.net/tw2y5omc/3/