The behavior of Mozilla in handling JQuery attr() function may result in variations in design elements such as font-family or font-size

I'm currently working on the login form.

Below is my view in CodeIgnitor:

<div id="login-form">
<?php
    echo heading('Login', 2);
    echo form_open('login/login_user');
    echo form_input('email', set_value('email', 'Email Address'));
    echo br();
    echo form_password('password', '', 'placeholder="Password" class="password"');
    echo br(2);
    echo form_submit('submit', 'Login');
    echo form_close();
    echo validation_errors('<p class="error">');
    ?>
</div>

My goal with JavaScript is to achieve the following functionality:

When a user clicks on the password field, it should become empty for them to input their password. If the user does not enter their password and clicks away, the field should display the placeholder "Password" again.

Here is the JavaScript code that accomplishes this:

$(':password').focusin(function(){
    if ($(this).attr('placeholder') !== undefined){
        $(this).removeAttr('placeholder')
    }
});

$(':password.password').focusout(function(){
    $(this).attr('placeholder', 'Password');
})

In addition, there is CSS that controls the color of the placeholder text (matching the input field color, #999999 in this case).

input[type=text],
input[type=password] {
    display: block;
    padding: 3%;
    color: #999999;
    margin: 0 0 1% 0;
    width: 90%;
    border: none;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;
    background: #202020;
}

::-webkit-input-placeholder {
   color: #999999;
}

:-moz-placeholder { /* Firefox 18- */
   color: #999999;
}

::-moz-placeholder {  /* Firefox 19+ */
   color: #999999;
}

:-ms-input-placeholder {  
    color: #999999;  
}

THE ISSUE IS that although the email and password fields appear consistent in Chrome and IE10, they look different in Mozilla. The color matches, but the font or size of the password field seems off, resulting in an inconsistent appearance.

Any insights as to why Mozilla displays the design differently (even though the JS functionality works fine)?

Thank you for your help...

You can also view the DEMO here.

Unfortunately, I cannot demonstrate the JS functionality at the moment, but you can see the issue by checking out the demo in both Mozilla and Chrome, for example.

Answer №1

Thank you so much for your assistance, but I am still curious about why the word "Password" appears lighter in Mozilla compared to "Email Address", while they look the same in Chrome. Feel free to check out the DEMO for reference.

This difference is due to the fact that the email field has a set value, whereas the password field uses a placeholder text.

    <input 
        type="text" 
        name="email" 
        value="Email Address"/>  <--------- Value
    <input 
        type="password" 
        name="password" 
        value=""         
        placeholder="Password" <--------- Placeholder
        class="password"/>

The color of the email text should match the default color of the textbox.

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

Improve the Popup to seamlessly elevate

In my project, I have implemented a pop-up dialog box that rises up from the left bottom corner as the user scrolls down the page. You can view it live at this link- However, I am facing an issue where the initial lift up of the dialog box is not smooth, ...

Is there someone who can assist me in transforming this constructor function into a factory function using Javascript?

const createAppError = (message, status) => { return { message, status }; }; This is the equivalent code using factory functions to create an AppError with a message and status. It achieves the same result as the constructor fun ...

Encountered an Error: UpdateCommand is not a valid constructor - AWS SDK v3 when running unit tests with Jest in Node.js

Every time the unit test reaches the point where it calls the UpdateCommand from @aws-sdk/lib-dynamodb, I encounter an error saying "TypeError: UpdateCommand is not a constructor". I suspect that there might be an issue with the mock. I'm unsure of ho ...

Collaborating and passing on a MongoDB connection to different JavaScript files

I am currently working with Node.js/Express.js/Monk.js and attempting to share my MongoDB connection across multiple JS files. Within apps.js, I have set up the following: var mongo = require('mongodb'); var monk = require('monk'); va ...

Mongoose Error: The function 'mongooseSchemahere' is not recognized as a valid function

Here is the mongoose Schema setup in models/user.js: const mongoose = require('mongoose'); const userSchema = mongoose.Schema({ loginId: String, firstname: String, lastname: String, eMail: String, password: String, acti ...

Obtaining the row number from a query and transferring it to another Google spreadsheet

I'm currently facing a challenge in extracting both cell data and the corresponding row number from a different sheet in Google Sheets. Although I have successfully formulated a query to retrieve all necessary column values, I'm struggling to inc ...

Data binding functions properly only when utilizing the syntax within the select ng-options

In the book AngularJS in Action, I came across this Angular controller: angular.module('Angello.Storyboard') .controller('StoryboardCtrl', function() { var storyboard = this; storyboard.currentStory = null; ...

Customizing CSS by replacing link file styles with code in the HEAD section

UPDATE: After further examination, it appears that the code is functioning correctly. My apologies for any confusion. I am attempting to override certain CSS rules on specific pages. Below is an example of my approach. Can anyone confirm if this is a vali ...

List in React without any unique identifiers

I have a list of numbers that I need to display in a table format. These numbers are fetched from an API call and not generated within my application. The data might change occasionally, but there are only around twenty values, so redrawing the entire tab ...

Achieve a div to fill the remaining width while using list-style-position: inside

I have been attempting to make another div occupy the remaining space in the numerical list item using list-style-position: inside, but it does not seem to be working for me. While I could opt for list-style-position: outside and add some spacing to avoid ...

Fixed navbar at the bottom of the page that transitions to static when scrolling reaches a certain location

Is it feasible to achieve this using Bootstrap v3? After conducting extensive research, it appears that a custom solution may be necessary. In essence, I am working with a navbar positioned at the bottom of the content area. Upon page load, if the navbar& ...

Creating HTML input elements dynamically using Javascript

<body> <form action="insertquestion.php" method="POST"> <script> function generateInputs(){ var prefix = "answer"; var number = 1; for(var i = 0; i < 5; i++){ ...

Ways to update a component upon becoming visible in Angular

Within my Angular 4.3.0 project, the header, left panel, and right panels are initially hidden on the login page until a successful login occurs. However, once they become visible, the data is not pre-loaded properly causing errors due to the ngOnInit meth ...

Angular ng-repeat with toggle filter

Looking for a way to display data in an angular application using ng-repeat? Want to add and remove filters on the displayed data with a simple click? You're in luck. Implementing a toggle filter functionality is easier than you think. If you've ...

What is the best way to eliminate vertical spacing among li elements in CSS

I am facing a challenge with my HTML code and styling, which is just an example: <div id="mn" style="margin-top:200px;"> <div class="first">1</div> <div class="second">2</div> & ...

Executing asynchronous functions synchronously

I am relatively new to JavaScript programming and I am currently trying to grasp the concepts of asynchronous processes. In my project, I am looking to execute the following code synchronously. Despite watching numerous tutorials on the subject, I find mos ...

Utilizing AngularJS ng-show to conditionally display content based on data retrieved from an

I am facing an issue with implementing the ngShow directive in my code, where I am trying to display data fetched from an API call. However, despite everything else working correctly, the ngShow directive does not seem to be functioning as expected. Here ...

Position navbar contents at the top of the screen

As I delve into learning Bootstrap4, I have come across the following snippet of HTML code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> ...

Ajax refreshes page to default state post search

I have implemented a live search feature that retrieves relevant information from the database and displays it in a table using Ajax to avoid page refresh. Currently, after each search, the results reset back to nothing until another input is received. How ...

Form a collection of visible table rows without hidden columns

My table allows users to filter out specific rows by selecting a checkbox. When a checkbox is checked, certain rows are hidden. I am trying to create an array with all the rows that are not hidden, but I am having trouble accessing the visibility state of ...