Hi all, I have ran into an error that I can't figure out how to fix. It's with the updateTips function on line 14 and the error is: tips.text(t).effect is not a function. This happens when I hit submit on the form.
Ah here is my code:
- <script type="text/javascript">
$(document).ready(function() {
var $loading = $('<img src="loading.gif" alt="loading" class="loading">');
var name = $("#name"),
shortname = $("#shortname"),
cname = $("#cname"),
address = $("#address"),
city = $("#city"),
state = $("#state"),
zip = $("#zip"),
phone = $("#phone"),
fax = $("#fax"),
email = $("#email"),
website = $("#url"),
allFields = $([]).add(name).add(shortname).add(cname).add(address).add(city).add(state).add(zip).add(phone).add(fax).add(email).add(website),
tips = $("#validateTips");
function updateTips(t) {
tips.text(t).effect("highlight",{},1500);
}
function checkLength(o,n,min,max) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass('ui-state-error');
updateTips("Length of " + n + " must be between "+min+" and "+max+".");
return false;
} else {
return true;
}
}
function checkRegexp(o,regexp,n) {
if ( !( regexp.test( o.val() ) ) ) {
o.addClass('ui-state-error');
updateTips(n);
return false;
} else {
return true;
}
}
function phoneValidate(o,n)
{
if(o.val().search(/\d{3}\-\d{3}\-\d{4}/)==-1)
{
o.addClass('ui-state-error');
updateTips(n + " number you entered is not valid. Please enter a phone number with the format xxx-xxx-xxxx.");
return false;
} else {
return true;
}
}
function zipValidation(o) {
reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
if (!reZip.test(o.val())) {
o.addClass('ui-state-error');
updateTips("Zip Code Is Not Valid");
return false;
}
return true;
}
$('#agencys img').each(function() {
var $dialog = $('<div></div>')
.append($loading.clone());
var $link = $(this).one('click', function() {
var saveLabel = $link.attr('sButton');
var cancelLabel = $link.attr('cButton');
var buttons = {};
buttons[cancelLabel] = function(){
$(this).dialog("close");
},
buttons[saveLabel] = function() {
var bValid = true;
allFields.removeClass('ui-state-error');
bValid = bValid && checkLength(name,"Agency Name",3,250);
bValid = bValid && checkRegexp(name,/^[a-z]([0-9a-z_])/i,"Agency Name may consist of a-z, 0-9, underscores, begin with a letter.");
bValid = bValid && checkLength(shortname,"Short Name",2,20);
bValid = bValid && checkRegexp(shortname,/^\w+$/,"Short Name may consist of a-z, 0-9, underscores, begin with a letter, no spaces.");
bValid = bValid && checkLength(cname,"Contact Name",3,250);
bValid = bValid && checkLength(address,"Address",3,250);
bValid = bValid && checkLength(city,"City",3,50);
bValid = bValid && checkLength(state,"State",2);
bValid = bValid && zipValidation(zip);
bValid = bValid && phoneValidate(phone,"Phone");
bValid = bValid && phoneValidate(fax,"Fax");
bValid = bValid && checkLength(email,"Email",6,250);
bValid = bValid && checkLength(website,"Website",6,250);
bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
if (bValid) {
$('#agencyForm').submit();
$(this).dialog('close');
}
}
$dialog
.load($link.attr('name') + ' #content')
.dialog({
title: $link.attr('title'),
width: 450,
height: $link.attr('vsize'),
modal: true,
buttons: buttons
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
return false;
});
});
});
</script>