/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Validation Plugin for jQuery

I have a javascript error somewhere not sure where but also is this the correct way I should be using the validation plugin for anyone who has used it.

[CODE]$(document).ready(function() {
$(‘div.message-error’).hide();
$(‘div.message-success’).hide();

$(“#arenaForm”).validate({
rules: {
arenaName: {
required: true,
},
locationName: {
required: true,
},
capacity: {
required: true,
},
},
messages: {
arenaName: “Please enter a name for the arena!”,
locationName: “Please enter the arena’s city and state!”,
capacity: “Please enter the arena’s capacity!”
}
submitHandler: function(form) {
var userID = $(“input#userID”).val();
var arenaName = $(“input#arenaName”).val();
var locationName = $(“input#locationName”).val();
var capacity = $(“input#capacity”).val();
var dataString = ‘userID=’ + userID + ‘&arenaName=’ + arenaName + ‘&locationName=’ + locationName + ‘&capacity=’ + capacity + ‘&submitArena=True’;
$.ajax({
type: “POST”,
url: “processes/arenas.php”,
data: dataString,
success: function(myNewVar) {
if (myNewVar == ‘good’) {
$(‘div.message-error’).hide();
$(“div.message-success”).html(“<h6>Operation successful</h6><p>” + arenaName + ” was saved successfully.</p>”);
$(“div.message-success”).show().delay(10000).hide(“slow”);
$(‘:input’,’#arenaForm’)
.not(‘:submit, :hidden’)
.val(”)
} else {
$(‘div.message-success’).hide();
$(“div.message-error”).html(“<h6>Operation unsuccessful</h6><p>” + arenaName + ” already exists in the database.</p>”);
$(“div.message-error”).show();
}
}
});
return false;
}
});
});
[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @xtremer360 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...