Hi,

Thanks for the shorthand tip, what I was trying to achieve is upon
sucessful validation call a function, its not a plugin. Its another
function written inside the DOM. I tried adding the live syntax and it
works the way I want it to but not sure if I have coded it right, code
reproduced below, all of the below codes are in the same DOM ready
function.


What I am trying to achieve is add set of input fields for my form, so
when user clicks 'add new' link the thickbox opens and you enter a
name for the new field this is validated with validateNAme and if
successful execute the addPhoneExt function and close the thickbox.

Thanks!

---------------------------------
        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').live("click",(addPhoneExt)); //Added 
to call the
addPhoneExt on successful validation
                        $('#addPhoneExt').live("click",(tb_remove)); //Added to 
call the
tb_remove to close the opened thickbox
                        name.removeClass("error");
                        nameInfo.text("What's your name?");
                        nameInfo.removeClass("error");
                        return true;
                }
        }

function addPhoneExt() {
        var label = $("#label").val();
        //current keeps track of how many people we have.
        current++;
        var strToAdd = '<div id="number_'+current+'" class="ctrlHolder"><p
class="label"><em>:</em> '+label+'</p><div class="multiField
phoneNum"><label for="phone_ccode_'+current+'"
class="blockLabel">Country <input type="text" id="phone_ccode_'+current
+'" name="phone_ccode_'+current+'" size="20" value=""
class="textInput" /></label><label for="phone_area_'+current+'"
class="blockLabel">Area <input type="text" id="phone_area_'+current+'"
name="phone_area_'+current+'" size="20" value="" class="textInput" /></
label><label for="phone_num_'+current+'" class="blockLabel">Phone
number<input type="text" id="phone_num_'+current+'"
name="phone_num_'+current+'" size="20" value="" class="textInput
phoneNumbr" /></label><label for="phone_ext_'+current+'"
class="blockLabel">Ext <input type="text" id="phone_ext_'+current+'"
name="phone_ext_'+current+'" size="20" value="" class="textInput" /></
label><img class="actions" src="img/remove_16.png" title="Remove"
onClick="removeFormField(\'#number_'+current+'\')" /><div
class="tags"><input name="radio-button-'+current+'" type="radio"
value="public" id="yes_'+current+'" checked="checked" /><label
for="yes_'+current+'">public</label><input name="radio-button-'+current
+'" type="radio" value="private" id="no_'+current+'" /><label
for="no_'+current+'">private</label><span style="display:block;"
class="tags-cbox"><input name="" type="checkbox" value=""
id="friends_'+current+'" checked="checked" /><label
for="friends_'+current+'">friends</label><input name=""
type="checkbox" value="" id="family_'+current+'" /><label
for="family_'+current+'">family</label><input name="" type="checkbox"
value="" id="work_'+current+'" /><label for="work_'+current+'">work</
label></span></div></div></div>'
        $('#mainField').append(strToAdd)
}
---------------------------------

Reply via email to