JavaScript Document jQuery fn validate function options var options jQ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// JavaScript Document
jQuery.fn.validate = function(options)
{
var options = jQuery.extend({
errorColor : '#FDFDD7',
borderColor : '#FE332E'
}, options);
var errorAmount = 0;
return this.find(':text').each(function()
{
var currentField = jQuery(this);
if (currentField.attr('requied'))
{
if (currentField.val()=='')
{
errorAmount++;
currentField.css('background-color', options.errorColor).css('border', '1px solid '+options.borderColor);
}
else
{
errorAmount--;
currentField.removeAttr('style');
}
}
});
if (errorAmount>0)
{
jQuery(this).find(':submit').attr('disabled', true);
}
else
{
jQuery(this).find(':submit').attr('disabled', false);
}
}