Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I'm trying to do something extremely simple yet can not get it to work.
 
I need to get the value of a tooltip and compare it to the text that is currently in a textbox. I want to do it in javascript so that I can post a client-side pop up confirm before I send it to the server. I can't seem get the textbox. I've tried using jquery and the title and innertext properties are blank even though when I hit f12, the title and value are there.
 
function confirmHiredChange(ctrl) {
        debugger;
        var row = $("tr[id=trid]");
        var tbHiredDtm = row.find("input[id$=tbeRecruitHiredDtm]");
        if (tbHiredDtm[0].title != "")
            return true;
        else if (tbHiredDtm[0].value == "")
            return true;
        return confirm('Are you sure you want to update this __?');
    }
 
this executes onclientclick and returns the confirm. I only want to show if the tooltip was previously not set (string.empty) and text value is set (! string.empty). It finds the textbox but no matter what I do, both properties are defined as "" when I come to tbHiredDtm[0] even though when I hit f12 it shows them.
 
I know it is something small that I am doing wrong, so if you see it feel free to let me know. Or if you know of a better way let me know that as well.
 
EDIT: TLDR- Basically how can I, in javascript, get the tooltip value of an asp:textbox ?
Posted 15-Feb-13 5:06am
Edited 15-Feb-13 5:20am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In your example (assuming tbHiredDtm is the what you want the title of) :
 
var title = $(tbHiredDtm).attr("title");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I think this is what you are looking for...
function confirmHiredChange(ctrl) {
        debugger;
        var row = $("tr[id=trid]");
        var tbHiredDtm = row.find("input[id$=tbeRecruitHiredDtm]");
        if ($(tbHiredDtm).attr("title") != "")
            return true;
        else if ($(tbHiredDtm).val() == "")
            return true;
        return confirm('Are you sure you want to update this __?');
    }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

The problem was that the server creates an ID for the textbox so I can't jquery select by the client ID... unless I do it like this
 
function confirmHiredChange(ctrl) {
    var tb = $("#<%= tbRecruitHiredDtm.ClientID %>");
    var hireddtm = tb.attr("title");
    if (hireddtm !== "" && hireddtm !== undefined)
        return true;
    else if (tb.val() === "")
        return true;        
return confirm('Are you sure you want to update this __?');
    }
That correctly selects the server created ID for me. Also the === compare is slightly faster as it compares via direct compare.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 490
1 Gihan Liyanage 338
2 ChauhanAjay 180
3 Vinay Mistry 160
4 Sergey Alexandrovich Kryukov 138
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100