Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: jQuery validation .NET4
jQuery.validator.addMethod("mail", function (value, element) {
var f = 0;
type: "get",
url: "Master/chkmail",
async: true,
cache: false,
data: { mail: function () { return $("#email").val(); } },
dataType: "json",
success: function (data) { if (data == true) { f = 1; } else { f = 0; }
error: function () { alert(arguments[1]); }
return f < 0 ? false : true;
public JsonResult chkmail(string mail)
JsonResult result = new JsonResult();
BLL.Member bll = bll = new MvcBBS.BLL.Member();
if (bll.emailExists(mail))
result.Data = true;
result.Data = false;
return result;
Please help me,thanks a lot
Posted 16-Dec-12 15:17pm
Christian Graus at 16-Dec-12 20:39pm
why do you use jQuery. instead of $. ? It makes your code hard to read compared to the accepted norm
Sergey Alexandrovich Kryukov at 6-Mar-13 15:23pm
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

data: { mail: function () { return $("#email").val(); } },
Does this even work ? Why not get the value and put it in to the data in another line of code ?
Have you debugged in Chrome ? What line has the error ?
gavinv at 16-Dec-12 20:52pm
the chkmail can get the value from that code, i've checked it. I just test this in
IE9.The problem is when i run this set of code it just show me that "email" already exsited, maybe this prove that "success" can't get the json from "chkmail"
gavinv at 16-Dec-12 21:01pm
The validate code is :
$(document).ready(function () {
rules: {
username: { required: true
password: { required: true }
messages: {
username: { required: '  input it!' },
email: { required: '  please input!', email: '  like!', mail: '  already exsited!' },
password: { required: 'pealse input!' }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.150302.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100