TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sheikh parvaz
NA
199
108.6k
Jquery server side validation in mvc
Mar 30 2017 3:04 AM
I am validating a name form serverside but it is shows me error message without validating and without calling conroller action method.
<script>
try
{
var
apiUrl =
'@Url.Action("Validate", "ServerValidations")'
;
$(
'#formAdd'
).validate({
errorElement:
'span'
,
//default input error message container
errorClass:
'help-block help-block-error'
,
// default input error message class
focusInvalid:
false
,
// do not focus the last invalid input
ignore:
""
,
// validate all fields including form hidden input
messages: {
Name: {
required:
'Please enter Name'
,
maxlength:
'Length exceeded! Size should be less than 50 characters'
,
VerifyName:
"This Job title already exist in "
}
},
rules: {
ArName: {
maxlength: 50,
required:
true
,
VerifyrName:
true
}
}
});
}
catch
(err) {
// alert(err.message);
}
function
addVerifyNameRule(apiUrl, errMessage) {
//alert('add rule :'+apiUrl);
jQuery.validator.addMethod(
"VerifyName"
,
function
(value, element) {
//alert('call validator');
$.ajax({
type:
'POST'
,
dataType:
'json'
,
async:
false
,
url: apiUrl,
data: {
'Value'
: value,
'ValidateRule'
: 1 },
success:
function
(result) {
alert(
'res'
);
if
(result[
'ValidateResult'
] ==
'1'
) {
return
true
;
//alert('valid!');
}
else
{
return
false
;
//alert('not valid!');
}
},
error:
function
(err) {
return
false
;
//alert('error : ' + err.message);
}
});
// return result;
}, errMessage);
Reply
Answers (
4
)
What does extension method i.e. GetNullEmptyMessage() do ?
Get the AD users List