New space is formed as the input box gains focus on the signin field

I'm currently working on a sign-in page and implementing JQuery. Everything seems to be functioning properly except for a minor issue. The problem is that when the password field gains focus, it creates extra space in IE 8 and later versions only.

The main goal is to prevent the creation of space when the password field gains focus on IE 8 during sign-in.

Here are some images to illustrate the issue:

Before the mouse is focused [IE 8].

After the mouse is focused [IE 8].

Here is my HTML code:

<input name="ctl00$logInBox$UserName" type="text" maxlength="256" id="ctl00_logInBox_UserName" class="userName" autocomplete="off" placeholder="Username" />
<input name="ctl00$logInBox$Password_TXT" type="text" maxlength="256" id="ctl00_logInBox_Password_TXT" class="password" autocomplete="off" value="Password" style="display:none" />
<input name="ctl00$logInBox$Password" type="password" maxlength="256" id="ctl00_logInBox_Password" class="password" autocomplete="off" value="" />

And here is the JQuery code for this:

<script type="text/javascript">
            $(document).ready(function () {
                $('#ctl00_logInBox_Password').hide();

                $('#ctl00_logInBox_Password_TXT').show();

                $('#ctl00_logInBox_Password_TXT').focus(function () {
                    $(this).hide();
                    $('#ctl00_logInBox_Password').show().focus();
                });

                $('#ctl00_logInBox_Password').blur(function () {
                    if ($(this).val() == "") {
                        $(this).hide();
                        $('#ctl00_logInBox_Password_TXT').show();
                    }

                });

            });
</script>

Here is the CSS portion:

.login .field input.userName, .login .field input.password {
    background: none repeat scroll 0 0 #e9e9e9;
    border: 1px solid #e4e4e4;
    width: 18.3em !important; /*width value changed by sakthivel*/
    display: inline-block;
    line-height: 1.4 !important;
    font-size: 15px !important;
    width: 309px !important;
    padding: 5px 8px 6px !important;
    color: #808080;
}

Answer №1

To rectify this issue, there needs to be a unique style applied to the :focus. To troubleshoot, open Google Chrome, access dev tools, inspect the div element, and select the option labeled :foc. This will simulate focus without actually focusing on the item, allowing you to analyze the CSS properties on the right panel for any potential causes.

It would also be beneficial to create a fiddle for others to test and provide assistance.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Page designed for displaying small star ratings in JSP

In the realm of my star.jsp page, the style.css is its trusty companion, faithfully executing its duties. However, a desire has crept into my heart - I yearn for the stars to shrink in size. The Chronicles of My Code star.jsp <!DOCTYPE html> ...

Avoid overwriting the success response parameter in jQuery Ajax

I've encountered a perplexing issue where the response parameter from the first ajax call is being overridden by the second call's parameter. Here is the code snippet: http://pastebin.com/degWRs3V Whenever both drawDonutForExternalLogin and dra ...

What is the best way to implement CSS Background-size: cover; while also making room for a menu?

Recently, I came across the CSS property background-size: cover, but I encountered a problem. I want the area behind my navigation on the left to be black. However, when I leave black space in the image itself, it gets cropped off when the image resizes. ...

Exploring the Module System of TypeScript

I am working with a TypeScript module structured like this: let function test(){ //... } export default test; My goal is for tsc to compile it in the following way: let function test(){ //... } module.exports = test; However, upon compilation, ...

Revamping the ejs template using an AJAX call

In my web app, users can search for recipes based on specific ingredients using the Edamam API. I implemented pagination to allow users to load more recipes when they click the "Load more" button, as Edamam only returns 20 recipes at a time. Here's ho ...

Using jQuery, is it possible to retrieve the product name and image dynamically?

I'm currently working on implementing an add to cart functionality using jQuery. When the add to cart button is clicked, the product name and image should be displayed. I can achieve this statically but I need help figuring out how to dynamically retr ...

Order an array depending on various strings

I am faced with the challenge of reordering a JSON array to mimic a conversation thread structure using Javascript. The initial array looks like this: var all_messages = [{ name: 'user1', replying_to: '', message: 'xxxxx&apo ...

Obtain the Ajax URL from a different webpage

I have been exploring various methods to access the ajax function of a website. Here is the code snippet I am working with: $.ajax({ type: 'POST', url: 'sched', //more code here.. }); It's worth noting that in the UR ...

I require the box element within my section element to have a full-width layout

Looking at the code in the image, you can see that I am using MUI components. Within a section, there is a box containing navigation filter links. The red part represents the section, while the white inside is the navigation link bar. My goal is for this b ...

Performing a reverse image search request using Javascript/AJAX to query Google

I have been attempting to perform a reverse image search request using AJAX, but I keep receiving 302 errors. After checking the Firebug console, I discovered that the response header from Google contains a URL linking me to the results. However, I am unsu ...

Troubleshooting V-model errors within VueJS components

Just dipping into VueJS and trying out a chat feature from a tutorial. I noticed the tutorial uses v-model in a component, but when I replicate it, the component doesn't display on the screen and the console throws a "text is not defined" error. Strug ...

WebGl - Perspective skewing perspective

I've been working on implementing an oblique projection in WebGL, but I'm encountering an issue where the projection appears identical to ortho. Here's the snippet of code setting up the projection matrix: mat4.identityMatrix(pMatrix); ...

Angular request accessing CoinMarketCap API

Currently, I am immersing myself in the world of the latest CoinMarketCap API and navigating through the waters of data. The Node.js example below demonstrates how to make a request. But how can I achieve the same in Angular? Any tips or suggestions would ...

Trouble with setInterval not refreshing the HTML element

I'm currently working on a script that should update the value of an element every second. However, I've encountered an issue where the element only updates the first time and then stops. Strangely, there are no errors appearing in the console ei ...

The functionality of .map() in Javascript is non-existent

I am completely new to this community (and JavaScript is also new for me), so I apologize in advance for asking some very basic questions. I have an HTML page with various images, all of which share a common class. After using getElementsByClassName, I obt ...

Collaborate and pass around SQL connections among different modules

One of my recently developed modules consists of three main functions: Establishing a SQL connection Executing a query Closing the connection This module is called in script.js along with other custom modules responsible for various operations that requi ...

What could be causing the invalid hooks error to appear in the console?

I'm completely stumped as to why this error is popping up when I try to use mutations with React Query. Any insights or advice would be greatly appreciated. Note: I'm implementing this within a function component in React, so it's puzzling ...

What types of devices are compatible with the different versions of the Android operating system?

I am currently working on a jquerymobile application for Android versions 2, 3, and 4, as well as iPhone, iPad, and iPod touch. I am analyzing user-agent strings using jQuery and jquerymobile. After testing with an emulator, I have noticed that all device ...

The datetimepicker is not functioning properly

I'm experiencing an issue with the datetimepicker where it doesn't display a calendar when I click the icon. Interestingly, the Chrome browser isn't showing any errors in the development console. <script src="Scripts/jquery-2.1.1.min.js ...

Encountering difficulties with showing contact images in phonegap using angularjs

In my project, I encountered an issue where I can fetch and display the contact photo using simple HTML and JavaScript. However, when I attempt to do the same using AngularJS model, I encounter an error. Below is the code snippet that I am struggling with: ...