Click here to Skip to main content
15,919,121 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have a page which is having two textboxes and one more link (a href ) and Next button to go for next page.

All are mandotory fields.

Now In case user forgot/missed to click on the Link ,and click on next/submit button ,I need to give a pop up by stating "Please click on the link " and redirect the flow to linked page once he clicked on pop up.This pop up will display only in this condition only

I have tried not select tag in Jquery but unable to get the logic for whether the link is clicked or not?

Please suggest me how to do with Jquery,JS, jsp.

Thanks .
Updated 28-Aug-14 4:26am

1 solution

I would recommend using the custom data- attribute on the element. Make your link look something like...

<a href="some link" id="infoLink" data-clicked="false" ...="">

then using the attr() function in jQuery you can read and set the value.

$("#nextButton").click(function(event) {
    if(false == $("#infoLink").attr("data-clicked")) {
        // display your popup
        // prevent event from going any further

$("#infoLink").click(function() {
    // change the custom data attribute
    $(this).attr("data-clicked", "true");
Share this answer
Sergey Alexandrovich Kryukov 28-Aug-14 16:21pm    
This technique should work, only the use of "data-..." attribute is totally redundant (and may not be supported by all browser; I'm not sure).
This is Javascript; you can add any property to the object (in this case, wrapper returned from selector #('...')). On first call, this property will be underfined, but on $("#infoLink") click you add the property, so it becomes some defined object on next $("#nextButton") click, which can be checked up with simple "if(wrapperObject)". It will make this code much simpler and less depending on the browser.
Dennis E White 28-Aug-14 16:27pm    
I have used the "data-" attribute with IE 8+, chrome, firefox and safari and haven't had any issues with it. with later releases of HTML the requirement/support was formalized and actually included into the spec.
Sergey Alexandrovich Kryukov 28-Aug-14 16:56pm    
All right, good to know, thank you. Still, its use is redundant, because no attribute is really needed when jQuery wrapper objects are used.
pratap420 30-Aug-14 1:57am    
Thanks all for your suggestions.

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900