The following code doesn't give any output. I think the expression might not be compatible with Javascript, it was working properly with PHP. I can't see the mistake anywhere else.
$(document).ready(function()
{
$("#saatjanimi").blur(function()
{
var input = $(this);
var reg = /^([-,.'\s\p{L}]*\s+[-,.'\s\p{L}]*)+$/;
if (!input.val().length || !reg.test(input.val()))
{
alert("asd");
input.after("Avalduse täitja nime lahter peab sisaldama täisnime.");
}
});
});