Don't mix up the RegExp constructor with regex literals. Use either
/^[a-zA-Z0-9._-]+\\[a-zA-Z0-9.-]$/
or
new RegExp("^[a-zA-Z0-9._-]+\\\\[a-zA-Z0-9.-]$");
Not sure what the backslash does in there, btw. Did you want to match a dot? In literal, use \., in string use \\..