I’m using this watermark plugin for jQuery. It works fine on every page except for my registration where it gets called 4 times. On the registration page I am getting a too much recursion error on line 57 of jQuery (one hosted on Google). I don’t think it’s jQuery that is the problem, though I think it has to do with my code or that plugin. Can you look to see if you see anything?
Code:
$(document).ready(function(){
$(".text").addClass("idleField");
$(".text").focus(function(){
$(this).removeClass("idleField");
$(this).addClass("focusField");
});
$(".text").blur(function(){
$(this).removeClass("focusField");
$(this).addClass("idleField");
});
$("#recaptcha_response_field").attr("tabindex","5");
<?php if(!is_ie()){ ?>
$("#username").watermark("Desired Username");
$("#password").watermark("Password between 6 and 12 characters");
$("#confirmPassword").watermark("Confirm Password");
$("#email").watermark("Please insert a valid email");
<?php } ?>
$("#checkUser").click(function(){
$("#results").html("<img src='images/loading.gif' alt='loading...' />loading...");
var user = $("#username").attr("value");
$.get("library/regUserCheck.php", {name: user}, function(data){
$("#results").html(data);
});
});
<?php if($error){ //Make error fade out ?>
$("#errorField").delay(5000).fadeOut(1250);
<?php } ?>
});
Too much recursion in your code, doesn’t that mean anything for you? Here’s the improved code:
Tips:
/*@cc_on … */) to handle IE, no need to do that with PHP.If you can’t do that, cache it to a variable. Example:
For example, if you want to specify more CSS rules for an element, this is the best syntax:
$(function() {as a shorthand for$(document).ready(function() {.I hope that’s enough. 🙂