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 9166123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:05:08+00:00 2026-06-17T15:05:08+00:00

Hi I want to implement into my plugin a function inside an object. The

  • 0

Hi I want to implement into my plugin a function inside an object.
The goal is:
I have many input with a default value.
When I click on It if the value is “default value” cancel the text inside. And this it works.
The problem is now that:
When I submit the form I call a function that check parameter and I want that if the input type have the default value cancel the value. But now only the last element do that and not all object. I have create a function inside the main function of the plugin. How to check every object inside the plugin when submit and check if has the default value or not?

my plugin:

(function($){
     $.fn.extend({      
        contact: function(options) {
            var defaults = {
            }

            var options =  $.extend(defaults, options);

            return this.each(function() {
                var o = options;
                var obj = $(this);      
                var value_base = obj.val();

                obj.click(function(){
                    if(obj.val()== value_base){
                        obj.val("");
                    }
                });
                obj.blur(function() {
                    if (obj.val() == ''){
                        obj.val(value_base);
                    }
                });

                $.fn.afterSubmit = function(options) {
                    if(obj.val()== value_base){
                        obj.val("");
                    }
                };

            });
        }
    });     
})(jQuery);

the code inside my page

<script type="text/javascript">
$(document).ready(function() {
    $('.contact').contact();
});
function autoriz(){
    $('.contact').afterSubmit();
    return false;
}
</script>
<form method="post" action="contatti.php" onSubmit="return autoriz();" enctype="multipart/form-data" name="contatti">
   <input type="text" name="name" class="contact" value="Name" id="name"/>
   <input type="text" name="surname" class="contact" value="Surname" id="surname"/>
</form>
  • 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-06-17T15:05:10+00:00Added an answer on June 17, 2026 at 3:05 pm

    Take a look at this fiddle http://fiddle.jshell.net/YskZy/

    In this example we bind the event submit passing the form id, so before the form is submitted, we can clear the default values

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

Sidebar

Related Questions

I have this idea that I want to implement into my project. I know
I want to implement semantic search into my rails site. I currently have a
I want to implement Highcharts into my projects and want to include color coded
I followed this tutorial to implement facebook into my application. All I want is
i starter in jqgrid, i want implement inline edit in jqgrid i have this
I am stucked with an idea I want to implement into one of my
I've implemented the nyroModal jQuery Plugin into my website. I have set up a
I want to display the facebook recommendations plugin when user is login into facebook.
I have NPAPI plugin and I want to detect its version before I embed
I want to implement this <img src=<?php echo z_taxonomy_image_url($cat->term_id); ?> /> into the following

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.