While not what you were asking, remember that you can chain. var name = $("#label"); var nameInfo = $("#nameInfo");
name.blur(validateName).keyup(validateName); ... nameInfo.text("We want names with more than 3 letters!").addClass ("error"); Then: $('#addPhoneExt').click(tb_remove); sets an onclick event handler on what the selector returns. I'm not exactly sure what you are asking... is there a function attached to the DOM node that you are trying to execute... are you trying to execute the already set click event? Are you trying to use a function created by a plugin? On Mar 21, 9:57 am, mdjamal <mail4ja...@gmail.com> wrote: > Hi, > > I am trying to call/execute a jQuery function inside of another jQuery > function, the scenario is after validation of a input text field to > check if its empty, if empty display a error message and if it has > value then execute another function, the code as below, adapted from > this link > > http://yensdesign.com/2009/01/how-validate-forms-both-sides-using-php... > > var name = $("#label"); > var nameInfo = $("#nameInfo"); > //On blur > name.blur(validateName); > //On key press > name.keyup(validateName); > $("#addPhoneExt").click(validateName); > //On Submitting > //$("#addPhoneExt").click(function(){ > //if(validateName()) > //return true > //else > //return false; > //}); > > function validateName(){ > //if it's NOT valid > if(name.val().length < 4){ > name.addClass("error"); > nameInfo.text("We want names with more than 3 > letters!"); > nameInfo.addClass("error"); > return false; > } > //if it's valid > else{ > $('#addPhoneExt').click(addPhoneExt); > name.removeClass("error"); > nameInfo.text("What's your name?"); > nameInfo.removeClass("error"); > //$('#addPhoneExt').click(tb_remove); > return true; > } > } > > With the above code I am able to validate the input field but what I > need is to execute or call the "addPhoneExt" "tb_remove" (function to > close thickBox) function //if its valid. > > Appreciate your help. > > Thanks!