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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:59:05+00:00 2026-06-01T23:59:05+00:00

jQuery Code : (function($){ $.fn.jgtextdefault = function(settings){ var jElements = this; var settings =

  • 0

jQuery Code :

(function($){
$.fn.jgtextdefault = function(settings){
var jElements = this;
var settings = $.extend({}, $.fn.jgtextdefault.defaults, settings);
return jElements.each(function(){
if($(jElements).is("input")){ jgTextDefault( $(jElements) ); }
});
function jgTextDefault(jInput){
if (jInput.val().length==0) jInput.val(settings.text);
jInput.focus(function () {
if (jInput.val()==settings.text) jInput.val('');
});
jInput.blur(function () {
if (jInput.val().length==0) jInput.val(settings.text);
});}};
$.fn.jgtextdefault.defaults = {
text: 'Default'
};
})(jQuery);

Php Code :

if (empty($releasedata['size'])) {
                $errors[] = '<li>'.Enter the size in GB.'</li>';
            }
if (empty($releasedata['releaseinfo'])) {
                $errors[] = '<li>'.Give more information.'</li>';
            }
        break;

Html Code :

  <script>
    $(document).ready(function(){

      $('#defaultText-releasename').jgtextdefault({'text':'This is the default text for release name'});
      $('#defaultText-releasesize').jgtextdefault({'text':'This is the default text for release size'});

    });
  </script>

Html (Input Fields) :

<input id="defaultText-releasename" type="text" name="releasename" value="$releasedata[releasename]" />

My Problem :
Everything is fine with displaying default text in input fields and hide on focus. But the problem is, when i submit the form (if user/me do not type anything in input fields, then it takes the input field value as the default text.

Since you can see from above php code, i would like to display the error message if nothing typed into input fields by user. So i do not want form to be submitted with the default text in input fields…

Can someone please help me with this problem ?

Thanks in advance and regards…

  • 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-01T23:59:07+00:00Added an answer on June 1, 2026 at 11:59 pm

    Ok i solved my problem with another jQuery code which has “clear the pre-defined text when form is submitted” function…

    This may be useful for some other users too… So here is the code :

    $(document).ready(function(){
      $('.default').each(function(){
        var defaultVal = $(this).attr('title');
        $(this).focus(function(){
          if ($(this).val() == defaultVal){
            $(this).removeClass('active').val('');
          }
        })
        .blur(function(){
          if ($(this).val() == ''){
            $(this).addClass('active').val(defaultVal);
          }
        })
        .blur().addClass('active');
      });
      $('form').submit(function(){
        $('.default').each(function(){
          var defaultVal = $(this).attr('title');
          if ($(this).val() == defaultVal){
            $(this).val('');
          }
        });
      });
    });
    

    And HTML would be as :

    <input type="text" name="text1" value="" class="default" title="Default Text 1" />
    

    All credits goes to : DesignChemical…

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

Sidebar

Related Questions

Revised Code jQuery(function($) { $(#filter).keyup(function () { var filter = $(this).val(), count = 0;
This is the Jquery code: function Totalprice() { var unitprice=$('#unitpay').val(); var quota=$('#readers').val(); var totalprice=unitprice*quota;
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
Here is my jQuery code: function onSaveClicked() { var message = { MessageID: $(#MessageID).val()
I have the following function in my jQuery code: function checkUNSelectBox(item){ $('#DELETE option').each(function(){ <!--alert(item);-->
jQuery Code: $(document).ready(function(){ $.getJSON('dat.js', function(data) { var obj = JSON.parse(data); alert(obj[0].title); }); }); My
Here is my Jquery code: $('#unblockButton').click(function () { var blockedlist = []; var count
I have the following JQuery code: $(document).ready(function () { var $containerHeight = $(window).height(); if
Here is my jquery code: $('input').click(function(){ $('h1').empty().queue(function(){ console.log('queue'); }); }); }); Only the first
I have jQUery code: setInterval(function() { var grayarrow = jQuery(ul#dropdowngray).parent(); var greenarrow = jQuery(ul#dropdown).parent();

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.