The submission of a Vue form is unsuccessful when it contains a hidden field

When users login to my application, they first enter their email address like in Google Account login. Depending on the scenario, they are then redirected to a Single Sign-On (SSO) or shown a password field.

In the Chromium documentation, this process is referred to as the "Email First Sign-in Flow", and Google recommends a specific form structure to help password managers understand the form:

First, collect the email:

<form id="login" action="login.php" method="post"> 
  <input type="text" autocomplete="username">
  <input type="submit" value="Sign In!">
</form>

Then proceed to collect the password, with the email included as a hidden form value:

<style>
#emailfield {
  display: none;
}
</style>
<form id="login" action="login.php" method="post">
  <input id="emailfield" type="text" value="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfb2ba9fbaa7beb2afb3baf1abbaacab">[email protected]</a>" autocomplete="username">  
  <input type="password" autocomplete="current-password">
  <input type="submit" value="Sign In!">
</form>

I have implemented this flow using Vue and Vuetify as follows:

<template>
    // Vue template implementation goes here...
</template>

<script>
export default {
    // Vue script implementation goes here...
};

While pressing Enter works properly on the email form triggering the lookupEmail function, it does not have the same effect on the password form. Removing the hidden email field allows for normal submission behavior that triggers the submit event correctly, albeit without the populated email in the password manager.

Upon inspection with Vue DevTools, I noticed that the email field triggers both the keydown and submit events, while the password field only captures the keydown event but misses the submit event altogether.

The question remains: why does the presence of the hidden email field interfere with the form's ability to catch submit events?

Answer №1

It appears that there is a connection to the issue discussed in utilizing v-model on concealed fields.

By making the following code adjustment:

<input style="display:none" name="email" type="email" v-model="email" readonly autocomplete="username" />

to:

<input name="email" type="hidden" :value="email" autocomplete="username" />

it seems to resolve the problem.

Please note that both modifications are necessary: transitioning from display: none to type="hidden", and from v-model= to :value=

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

Is it possible to showcase two modals on a single page, positioning one to the left and the other to the right using Bootstrap?

Can someone help me learn how to display two modals on the same screen, one on the left and one on the right? I am new to bootstrap and would appreciate some guidance! ...

Transmitting the Vue.js data object to the backend with the assistance of Axios

My current challenge is sending the full data object of a Vue Instance to the back-end using axios. Below is the code snippet I'm working with: var vm = new Vue({ el: '#el', delimiters: ["[[", "]]"], data: { brand: 0, ...

The dynamic sidebar menu in Adminlte 3 with bootstrap-4 loaded from ajax is not functioning properly, presenting issues with sidebar

Is there a way to fetch dynamic sidebar menu data from the database using AJAX in the adminlte 3 dashboard along with bootstrap 4? I have tried loading the sidebar menu data dynamically using AJAX, but the sidebar open/close functionality is not working pr ...

receiving a pair of components instead of just one

Here is the code for router.js: import React from 'react'; import { Route } from 'react-router-dom'; import CommentList from './containers/commentview'; import CommentDetalList from './containers/commentdetailview'; ...

Unexpected element layout issues

Attempting to create a basic website that utilizes the flickr api, retrieves photos and details, and displays them using bootstrap. However, there seems to be an issue that I am unsure how to resolve. Currently, my code is functioning like so: https://i.s ...

Dynamically load scripts in angularJs

Having multiple libraries and dependencies in my angularjs application is posing a challenge as I want to load them all using just one script, given that three apps are utilizing these dependencies. Currently, I have this custom script: var initDependenci ...

When transitioning an iOS Swift app to the background, a NodeJS error arises: 'Headers cannot be set after they have been sent to the client'

My app is built using Swift/SwiftUI. I utilize the ObservableObject and JSONDecoder to retrieve data from my Node.JS Express API and display it within the app: struct DevicesList: Decodable { var data: [DeviceInfo] } struct DeviceInfo: Decodable { ...

Testing a Svelte Component with Unit Tests { #conditionals }

Test Procedure Instructions To begin, execute the following bash command: mkdir example && cd example && mkdir src && touch jest.config.js && pnpm init && pnpm i @jest/globals @testing-library/svelte jest jest-envi ...

What is the best way to create a time delay between two consecutive desktop screenshot captures?

screenshot-desktop is a unique npm API that captures desktop screenshots and saves them upon request. However, I encounter the need to call the function three times with a 5-second delay between each call. Since this API works on promises, the calls are e ...

Tips for utilizing a .node file efficiently

While attempting to install node_mouse, I noticed that in my node modules folder there was a .node file extension instead of the usual .js file. How can I execute node_mouse with this file format? After some research, it seems like node_mouse may be an a ...

Passing intricate data structure from Angular to SignalR

I am encountering an issue when trying to send a complex object to my SignalR hub. The JavaScript object I'm sending matches perfectly with my C# object, so theoretically everything should be functioning correctly. However, for some reason, my UpdateE ...

Tips for utilizing Plunker or JSFiddle to execute Angular2 code

I've been attempting to practice coding programs in Angular 2 using plnkr and jsfiddle. However, every time I try to run them, I encounter issues such as 404 errors or exceptions when I check the developer tools. Can anyone advise on the correct metho ...

Encountering an issue with the date pipe in Angular that prevents

I'm trying to incorporate a date pipe in my AngularJS and Firebase project to display the creation date of a post. However, I am facing an issue where the date does not appear when testing it. Below is my create Post function: createPost() { con ...

How can I remove the focus highlight from the MUI DatePicker while retaining it for the TextField?

I am currently working on developing a date picker using react.js with the MUI DatePicker library. The code I have implemented closely resembles what is provided in their documentation. However, upon rendering the component, I am encountering an issue whe ...

Tips for simulating the 'this' keyword within Jest test scenarios

Within my JS script, there is a similar structure: window.custom_object = { //custom function defined myFunction: function(param1,param2){ } myNewFunction : function(){ //attempting to call myFunction ...

Executing a TypeORM query with a distinct clause that ignores case sensitivity

I am attempting to construct a TypeORM query builder that pulls data from a postgresql database to retrieve all unique names. Here is how my query currently looks: names = await this._context.manager .getRepository(Names) .createQueryBuilde ...

Navigating through the React components using react-router and accessing the props can

Is there a way to access this.props from the <Router>'s onUpdate function? I need to know the current route and access this.props.route in order to identify the page (name). Unfortunately, I haven't found any resources on how to achieve thi ...

Slideshow elements removed

I attempted to remove my links individually from the div id="wrapper", but unfortunately have encountered an issue while doing so: window.onload = function () { setInterval(function () { var wrapper = document.getElementById("wrapper"); var my_l ...

Setting the current date of a jQuery datepicker to the value of an input tag

I am looking to assign a value to an input tag that has a datepicker attached to it. Upon initialization of the datepicker, I want to set this value. Below is a hypothetical example of what I am trying to achieve: HTML: <input id="test" value="">&l ...

Using AngularJS Scope to Map an Array within a JSON Array

I'm attempting to extract the type and url values from the media2 object within this JSON array and assign them to an AngularJS scope Array. "results":[ { "session2":[ { "__type":"Object", "abou ...