A regex is needed which should have only special character dot which should either be optional or occur only once.
pattern = /^([A-Za-z.]+)$/;
Here are some ways to do it:
Deal separately where the input has has one dot, with optional letters surrounding it, or no dot (but then having at least one letter):
Just capture letters and dots like you did, but don't allow the input to have two dots, using a negative look ahead:
Capture optional letters then an optional point and then optional letters, but forbid an empty input with a negative look-ahead:
If in any case the dot should not be at the start or end and not match an empty string, you can start the match with 1 or more chars a-z and then optionally match a dot and again 1 or more chars a-z:
/^[a-z]+(?:\.[a-z]+)?$/i