Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:47:36+00:00 2026-05-25T20:47:36+00:00

I am stuck. Searched and tried for hours. EDIT: I still can’t make it

  • 0

I am stuck. Searched and tried for hours.

EDIT:
I still can’t make it work. Okay, I’ll just put the source code to make it clear what I want to accomplish.

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script type="text/javascript">
    var date_fmt="yyyy-mm-dd";
    var time_fmt="HH:MM";
    var date_field="#id_start_0, #id_end_0"; //id refering to html input type='text'
    var time_field="#id_start_1, #id_end_1"; //id refereing to html input type='text'


    function clearFmt(fmt_type)
    { 
        if($(this).val() == fmt_type) {
            $(this).val("");

        }
    }

    function putFmt(fmt_type)
    {
        if($(this).val() == "") {
            $(this).val(fmt_type);
        }
    }


$(document).ready(function() {

    $(date_field).attr("title",date_fmt);
    $(time_field).attr("title",time_fmt);

    $(date_field).click(function() {
        clearFmt(date_fmt);
    });   

    $(date_field).blur(function(){
        putFmt(date_fmt);
    });

    $(time_field).click(function(){
        clearFmt(time_fmt);
    });   

    $(time_field).blur(function(){
        putFmt(time_fmt);
    });

});
</script>

Help ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:47:37+00:00Added an answer on May 25, 2026 at 8:47 pm

    Use the jquery bind method:

    function myfunc(param) {
        alert(param.data.key);
    }
    
    $(document).ready( function() {
        $("#foo").bind('click', { key: 'value' }, myfunc);
    });
    

    Also see my jsfiddle.

    === UPDATE ===

    since jquery 1.4.3 you also can use:

    function myfunc(param) {
        alert(param.data.key);
    }
    
    $(document).ready( function() {
        $("#foo").click({ key: 'value' }, myfunc);
    });
    

    Also see my second jsfiddle.

    === UPDATE 2 ===

    Each function has his own this. After calling clearFmt in this function this is no longer the clicked element. I have two similar solutions:

    In your functions add a parameter called e.g. element and replace $(this) with element.

    function clearFmt(element, fmt_type) {
        if (element.val() == fmt_type) {
            element.val("");
        }
    }
    

    Calling the function you have to add the parameter $(this).

    $(date_field).click(function() {
        clearFmt($(this), date_fmt);
    }); 
    

    Also see my third jsfiddle.

    -=-

    An alternative:

    function clearFmt(o) {
        if ($(o.currentTarget).val() == o.data.fmt_type) {
            $(o.currentTarget).val("");
        }
    }
    $(date_field).click({fmt_type: date_fmt}, clearFmt); 
    

    Also see my fourth jsfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I searched the net for hours, but I'm stuck. I used a tutorial for
I am stuck with this issue for a long time. I searched for this
I have searched apple's documentation and other posts on Stack Overflow, but I'm still
I searched a lot online but stuck with doubts in RSA public key and
i've been stuck on a problem and can't seem to find any help for
i'm working on a project and i have some problems.I have searched but can
After some searches via Google, I can't think of other keywords and am still
I've been stuck with this problem from a couple of days and I can't
i'm stuck on this process from two days, before posting i've searched a lot
I searched through other questions but can't find a working solution for my project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.