Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: why Remote Validation is not firing

Vondella21:

i tried to to validate my Username remotely ,unfortunately is not firing here are my codes for viewmodel


public class UsersNew
{
public IList Roles { get; set; }

[Required,StringLength(6,MinimumLength =3)]
[Remote("IsAvailable","Validation")]
[RegularExpression(@"(\S)+",ErrorMessage = "White space is not allowed.")]
public string username { get; set; }

[Required,DataType(DataType.Password)]
public string password { get; set; }

[Required,MaxLength(256),DataType(DataType.EmailAddress)]
public string email { get; set; }
}

my controller


public class ValidationController : Controller
{

public JsonResult IsAvailable(string username)
{
if (!Database.Session.Query().Any(u => u.username == username))
return Json(true, JsonRequestBehavior.AllowGet);
string suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} is
not available ", username);

for (int i = 0; i {
string altCandidate = username + i.ToString();
if (!Database.Session.Query().Any(u => u.username == altCandidate))
{
suggestedUID = string.Format(CultureInfo.InvariantCulture, "{0} is not
available. Try {1}", username,
altCandidate);
break;
}

}
return Json("error", JsonRequestBehavior.AllowGet);
}
}

i even include default jquery validation


@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")

what am i doing wrong here?



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: why Remote Validation is not firing

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×