<script type="text/javascript">
<!--
$(document).ready(function() {
$("#form1").validate({
rules: {
budget: {
required: true,
minlength:3
} ,
duration: {
required: true,
digits:true
},
town: {
required: true,
minlength:2
},
content: {
required: true,
minlength:300
}
},
messages: {
}
});
});
-->
</script>
Two jquery files are included.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="../common/jquery.validate.js"></script>
are included. There is nothing wrong with the inclusion.
I got an error message
$("#form1").validate is not a function What's wrong?
This question is related to
jquery
jquery-validate
Had the same issue; validated HTML & found I was missing a name="email"
attribute from an <input />
. Always validate the HTML to be positive your HTML is valid. After I added it, validate()
worked perfectly.
I had this same issue. It turned out that I was loading the jQuery JavaScript file more than once on the page. This was due to included pages (or JSPs, in my case). Once I removed the duplicate reference to the jQuery js file, this error went away.
my solution to the problem:
in footer add <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
Probably the browser first downloaded the validade script and then jQuery. If the validade script be downloaded before loading jQuery you'll get an error. You can see this using a tool like firebug.
Try this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
function LoadValidade() {
var a = false;
try {
var teste = $('*');
if(teste == null)
throw 1;
} catch (e) {
a = true;
}
if (a){
setTimeout(LoadValidade, 300);
return;
}
var validadeScript = document.createElement("script");
validadeScript.src = "../common/jquery.validate.js";
$('head')[0].appendChild(validadeScript);
}
setTimeout(LoadValidade, 300);
</script>
I just encountered this extremely frustrating error and lost the better part of an hour to it, for lack of a workable answer online. I confirmed in Firebug that I was hitting the CDN for both jQuery and validation.
In the end, changing this:
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js"></script>
to this:
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
was all I needed.
Maybe silly, but check that you inline script is AFTER you include the script tags.
I had the same issue, and yes I had my jquery included first followed by the jquery validate script. I had no idea what was wrong. Turns out I was using a validate url that had moved. I figured this out by doing the following:
In my situation I had a 403 Forbidden error when trying to obtain (http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js which is used in the example on http://rocketsquared.com/wiki/Plugins/Validation ).
Turns out the that link (http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js) had moved to http://view.jquery.com/trunk/plugins/validate/jquery.validate.js (Firebug told me this when I loaded the file locally as opposed to on my web server).
NOTE: I tried using microsoft's CDN link also but it failed when I tried to load the javascript file in the browser with the correct url, there was some odd issue going on with the CDN site.
I had this issue, jquery URL was valid, everything looked good and validation still worked. After a hard refresh CTL+F5 the error went away in Chrome.
If you had a link I could look to see what the issue is but here are a couple questions and things to check:
Also, if you're going to use the Google CDN for getting jQuery you may as well use Microsoft's CDN for getting your validation file. Any of these URLs will work:
Check if you use Proxy.
I've got this problem in Mozilla Firefox, I thought it's some issue related to the Firefox itself. Later I found out that I am using a proxy server. When I unchecked the proxy, everything got fine.
youll need to use the latest http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js in conjunction with one of the Microsoft's CDN for getting your validation file.
In my case i moved the validate part outside of the document ready function and it works fine for me. I hope it would work for u...
$(document).ready(function () {
// paste validate function outside of the document ready function...
});
$('#form1').validate({
rules: {
English_Name: { required: true, minlength: 3 },
Arabic_Name: { required: true, minlength: 3 },
latitude: { required: true, min: 16, max: 32, number: true },
longitude: { required: true, min: 32, max: 52, number: true },
EmployeeID: { required: true },
PaymentTypeID: { required: true },
BusinessTypeID: { required: true },
SalesTypeID: { required: true },
OutletLength: { required: true },
OutletWidth: { required: true },
CONTACT_PERSON: { required: true },
MOBILE_NO: { required: true, minlength: 9, maxlength: 13, digits: true },
TRADE_LIC_DATE: { dateValidation: true },
CreditLimit: { min: 0, max: 2000000 },
CreditPeriod: { min: 0, max: 365 },
EMAIL_ADDRESS: { email: true },
BusinessClassID: { required: true },
CustomerClassificationID: { required: true },
LicenseTypeID: { required: true }
},
message: {
English_Name: {
required: ''
},
ToDate: {
required: ''
}
},
submitHandler: function (form) { // for demo
$.ajax({
type: 'POST',
url: '/sfa/Verification/SaveDataInDatabase',
data: $('form').serialize(),
beforeSend: function () {
$('.submitBtn').attr("disabled", "disabled");
$('.modal-body').css('opacity', '.5');
},
success: function (msg) {
$("#form1").trigger('reset');
$('.modal').modal('hide');
$('.submitBtn').removeAttr("disabled");
$('.modal-body').css('opacity', '');
}
});
}
});
Make sure that jQuery is using the $ variable, and its not another javascript framework.
Check your doctype: Validate your html, sometimes browsers don't see stuff in quirks mode, or when they encouter malformed html.
Also ensure that jquery.validate.js file is correct.
You can download it below:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Source: Stackoverflow.com