First you need to have two arguments sender and args
as
check(sender,args)
and you need to set
args.IsValid = false;
when you want to show error message. Rest thing will be take care by validator itself.
your check function would be as
function check(sender,args)
{
var pattern=/^[A-Za-z0-9]{10}$/;
var regexp = new RegExp(pattern);
if(regexp.test(document.getElementById("ctl00_ctl00_ContentPlaceHolder1_ContentProfile_txtMobileNumber").value))
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}