Issues with CSS 3 compliance verification are not being resolved

Hey there, I'm currently working on implementing a multi-step form. However, I've run into an issue with adding CSS 3 validation to the form fields as it doesn't seem to be working correctly. Whenever I try to include CSS 3 validation, it skips directly to the next page instead of validating the fields. Can anyone offer some guidance or assistance with this problem?

 <!-- multistep form -->
 <form id="msform">

    <!-- progressbar -->
    <ul id="progressbar">
        <li class="active">Account Setup</li>
        <li>Social Profiles</li>
        <li>Personal Details</li>
    </ul>

   <!-- fieldsets -->
    <fieldset>
        <h2 class="fs-title">Create your account</h2>
        <h3 class="fs-subtitle">This is step 1</h3>
        <input type="text" name="email" placeholder="Email" />
        <input type="password" name="pass" placeholder="Password" />
        <input type="password" name="cpass" placeholder="Confirm Password" />
        <input type="button" name="next" class="next action-button" value="Next" />
    </fieldset>

    <fieldset>
        <h2 class="fs-title">Social Profiles</h2>
        <h3 class="fs-subtitle">Your presence on the social network</h3>
        <input type="text" name="twitter" placeholder="Twitter" />
        <input type="text" name="facebook" placeholder="Facebook" />
        <input type="text" name="gplus" placeholder="Google Plus" />
        <input type="button" name="previous" class="previous action-button" value="Previous" />
        <input type="button" name="next" class="next action-button" value="Next" />
    </fieldset>

    <fieldset>
        <h2 class="fs-title">Personal Details</h2>
        <h3 class="fs-subtitle">We will never sell it</h3>
        <input type="text" name="fname" placeholder="First Name" />
        <input type="text" name="lname" placeholder="Last Name" />
        <input type="text" name="phone" placeholder="Phone" />
        <textarea name="address" placeholder="Address"></textarea>
        <input type="button" name="previous" class="previous action-button" value="Previous" />
        <input type="submit" name="submit" class="submit action-button" value="Submit" />
    </fieldset>

</form>

Javascript

CSS

The full code can be found in this pen: https://codepen.io/nickau/pen/xJJPqq

Answer №1

If you're looking to enhance your CSS skills, one option is to customize the styling of inputs based on certain conditions. Keep in mind that this feature may not be compatible with older browser versions.

/* Disable the next button when inputs are invalid */
#msform input:invalid + .next.action-button {
  opacity: 0.5;
  pointer-event: none;
}
/*
* Conditions for invalid input:
* 1. NOT empty
* 2. NOT in focus
* 3. NOT valid
*/
#msform input:invalid:not(:focus):not(:placeholder-shown) {
  border: 1px solid red;
}

To implement this, make sure to update your HTML code by adding the required attribute to the inputs. Additionally, for email fields, change the type to "email."

<input type="email" name="email" placeholder="Email" required />

You can explore different input types and their usage in HTML here.

For more advanced validation, consider using the "pattern" attribute:

<input type="text" name="name" placeholder="Name" pattern="[A-Za-z]+" required />

Further insights on form validation techniques can be found at this link.

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

Tips for utilizing jquery.load for fetching a section of an html document or an entire html file

I'm experimenting with jquery's load function to dynamically fetch and display HTML content, rather than using $.ajax(). I enjoy exploring the various features that jQuery offers and want to understand how each one works. Below is the code I am ...

Solving dependencies for npm modules

I have a project where I am utilizing a custom library to share Vue components across various applications. To achieve this, I have added my component library as an npm module and included it in the application's package.json file, which is functioni ...

consistently receiving identical IDs for all elements

Currently, I am working on a calendar feature where upon clicking on a specific date, I should be able to see a list associated with that date. However, when I click on any date, the entire list is displayed due to the ng-repeat attribute. Additionally, I ...

Angular animation triggered when a specific condition is satisfied

I am working on an animation within my Angular application @Component({ selector: 'app-portfolio', templateUrl: 'portfolio.page.html', styleUrls: ['portfolio.page.scss'], animations: [ trigger('slideInOut&apo ...

Regular expressions should be utilized in a way that they do not match exactly with a

Can someone help me create a regular expression for an html5 input pattern attribute that excludes specific items? How can I convert ab aba ba into a pattern that will match anything that is not exactly one of these words? For example, I want the fol ...

Guide: How to change a sibling component's state from another sibling or imported component in REACT

Greetings! I have recently delved into the world of ReactJS and have been experimenting with import and export functions. To give you an idea, my app has a structure consisting of 3 separate files - a parent component and two children components. My questi ...

Executing code after complete loading in Angular Bootstrap lifecycle

Angular's application module includes a run() block which executes after the config() function but before any controllers and directives are loaded. Is there a way to execute something in the lifecycle after all controllers, directives, services, etc ...

`Changing the Navbar Toggle Alignment in Bootstrap`

<!-- Navigation Bars --> <nav class="navbar navbar-expand-lg navbar-light"> <div class="container-fluid"> <!-- Hemburger Menu for Mobile Devices --> <button ...

Creating a Vue.js component that animates text to fade in and out within a textarea when a button

I need assistance with updating a <textarea> element in my Vue application. Currently, I have the textarea bound to some data in my state. However, when a button is clicked, I want the existing data in the textarea to fade out and be replaced with ne ...

Developing an interface that processes input text and implements it to perform various functions

UPDATE: Issue Resolved I've been working on creating an API to enable reading text from a word document and having the bot in botpress respond with a specific section of that text. I'm facing some confusion regarding the following aspects: ...

Extracting the console.log method from the console

Given that the console object has not been overridden and refers to a native object, the console.log method (and possibly others) is obtained from the console object with the following code: var log = obj.log = console.log; // instead of console.log.bind( ...

What distinguishes running rm -rf node_modules + npm i from using npm ci?

When using a Unix system and needing to clean out the node modules folder, is there any benefit or distinction between executing rm -rf node_modules followed by npm i as opposed to npm ci My understanding is that both yield the same outcome, but is th ...

Tips for customizing the appearance of jscrollpane in EasyUI

I need help customizing the jscrollpane style in EasyUI Frozen Columns for DataGrid. I've tried changing it using the following CSS: ::-webkit-scrollbar { width: 12px; } However, it doesn't seem to have any effect. ...

Space in the middle of a body and a div

After extensively searching for a solution to the issue plaguing my website, I found that there was always an annoying gap at the top of the page. Despite trying various solutions, none seemed to work. Upon inspecting the website in Firefox, I discovered t ...

Tips for loading images dynamically (or lazily) as they come into the user's view with scrolling

Many modern websites, such as Facebook and Google Image Search, display images below the fold only when a user scrolls down the page enough to bring them into view (even though the page source code shows X number of <img> tags, they are not initially ...

What is the best way to implement an automatic logout feature in asp.net that will log out my site after 10 minutes of inactivity?

Looking for a solution to automatically log out a site in asp.net when it is idle? Here's what you can do: Set the session timeout to 10 minutes in the web.config file under authentication. For instance, if the site has been idle for 9 minutes, you ca ...

Utilizing Smoke.js within a PHP environment

I created a PHP function to validate HTML form fields. When an error occurs, the code below will display an error message using JavaScript "alert": echo '<script type= "text/javascript">alert("account not found in database")</script>&apo ...

Achieve centered alignment for a website with floated elements while displaying the complete container background color

I am currently working on a website that consists of the basic elements like Container, Header, Content, and Footer. The container has a background-color that should cover the entire content of the site, including the header, content, and footer. However, ...

Applying Styles to Cells Using the Google Sheets API (v4)

Having encountered an issue while using the Google Sheets API (v4) for programmatically creating or updating spreadsheets, I have come across the following problem: According to the documentation (https://developers.google.com/sheets/api/reference/rest/v4 ...

Determine whether a given string is a valid URL and contains content

Is there a way to ensure that one of the input fields is not empty and that the #urlink follows the format of a URL before executing this function in JavaScript? $scope.favUrls.$add I'm uncertain about how to approach this. html <input type="te ...