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

  • Home
  • SEARCH
  • 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 8603649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:22:26+00:00 2026-06-12T02:22:26+00:00

I am trying to display an error text using jQuery, when the username field

  • 0

I am trying to display an error text using jQuery, when the username field is blank. This is not the problem, because I have done this already. The problem is that after the error text shows, I want to click the username field and hide the error text div, so that I can be able to reshow the error if the field is still blank using jQuery.

When I set the visibility to hidden in CSS using jQuery it automaticlly adds an display: hidden when I look at the code in Google Chrome’s inspector.

The code is in: http://albsocial.net84.net/

<?php include ("php/head.php"); ?>
<div id="wrapper">

    <div id="container">

        <div id="intro">

            <h2><center>Are you a member? Login ...</center></h2>
            <h3><center>And enjoy hundreds of services.</center></h3>



            <div id="log_form">

                <form action="php/login.php" method="post" class="login_form">

                    <input type="text" size="25" name="log_uname"
                           id="login_txt" placeholder="Your Username">
                    <input type="password" size="25" name="log_password" id="login_pass" placeholder="Your Password">
                    <label id="check"><input type="checkbox" name="checkbox">         Remember Me</label>
                    <input type="submit" name="submit1" id="login_sub" value="LogIn">
                    <img id="loading1" src="images/ajax-loader.gif" alt="working.." />



                    <script>
                        $('#login_txt').click(function (e) {
                            e.preventDefault();
                            $('#error1').fadeOut('fast', function () {
                                $(this).css("visibility","hidden");
                            });
                        });             
                    </script>

                </form>

                <div id="error1"></div>
            </div>

            <div id="new_users">
                <h4 class="h4_users">New Users ...</h4>

                <a href="#"><img src="#" width="55" height="55"></a>
                <a href="#"><img src="#" width="55" height="55"></a>
                <a href="#"><img src="#" width="55" height="55"></a>
                <a href="#"><img src="#" width="55" height="55"></a>
            </div>

        </div>

        <div id="register">
            <h2><center>Sign up Below ...</center></h2>
            <h3><center>Easy, fast and free!</center></h3>

            <form action="php/register.php" method="post" name="form" class="form">
                <input type="text" size="25" name="fname" placeholder="First Name">
                <input type="text" size="25" name="lname" placeholder="Last Name">
                <input type="text" size="25" name="username" placeholder="Username">
                <input type="text" size="25" name="email" placeholder="Email">
                <input type="text" size="25" name="email2" placeholder="Repeat Email">
                <input type="password" size="25" name="password" placeholder="Password">
                <input type="password" size="25" name="password2" placeholder="Repeat Password">
                <input type="submit" name="submit" id="sub" value="Sign Up!">
                <img id="loading" src="images/ajax-loader.gif" alt="working.." />
            </form>
            <div id="error"></div>
        </div>
    </div>

    <?php include("php/footer.php"); ?>

and the code im using to actually show or create the error code

$(document).ready(function(){

    $('.form').submit(function(e) {
        register();
        e.preventDefault();
    });

    $('.login_form').submit(function(e) {
        login();
        e.preventDefault();
    });

});

function register(){
    hideshow('loading',1);
    error(0);

    $.ajax({
        type: "POST",
        url: "php/register.php",
        data: $('.form').serialize(),
        dataType: "json",
        success: function(msg){
            if(parseInt(msg.status)==1){
                window.location=msg.txt;
            } else if(parseInt(msg.status)==0) {
                error(1,msg.txt);
            }
            hideshow('loading',0);
        }
    });
}

function login(){
    hideshow1('loading1',1);
    error1(0);

    $.ajax({
        type: "POST",
        url: "php/login.php",
        data: $('.login_form').serialize(),
        dataType: "json",
        success: function(msg1){
            if(parseInt(msg1.status1)==1){
                window.location=msg1.txt1;
            } else if (parseInt(msg1.status1) == 0) {
                error1(1,msg1.txt1);
            }
            hideshow1('loading1',0)
        }
    });
}
function hideshow(el,act){
    if(act) $('#'+el).css('visibility','visible');
    else $('#'+el).css('visibility','hidden');
}
function error(act,txt){
    hideshow('error',act);
    if(txt) $('#error').html(txt);
}
function hideshow1(el,act){
    if(act) $('#'+el).css('visibility','visible');
    else $('#'+el).css('visibility','hidden');
}
function error1(act,txt1){
    hideshow1('error1',act);
    if(txt1) $('#error1').html(txt1);
}
  • 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-12T02:22:27+00:00Added an answer on June 12, 2026 at 2:22 am

    try

    $('#error1').fadeOut('fast', function () {
       $(this).show()
       $(this).css("visibility","hidden")    
    })
    

    because fadeOut sets display:none; and you are also working with the visibility attribute, get rid of visibility and use .show() and .hide() instead

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

Sidebar

Related Questions

Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
I'm trying to display a modal form using jquery ui. I've adapted an example
I've been trying to get this really simple example of using AJAX with JQuery
I'm using this jQuery validation plugin and getting the famous: $(#Form).validate is not a
I am trying to display some cities in autocomplete using jquery and when any
I am trying to display an .svg file in a HTML page using jQuery
I'm trying to display a PHP variable using javascript/jquery but it's displaying 'null'. if(mysql_num_rows($checkBan)
I am trying to validate using jquery validation and the error messages displayed it
I received the error while trying to display some variable like so: echo id
trying to display data only after variables have been set. $(document).ready(function () { function

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.