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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:17:16+00:00 2026-06-18T01:17:16+00:00

I have a HTML File, that looks like this: Input 1: <input type=text required=false

  • 0

I have a HTML File, that looks like this:

        Input 1: <input type="text" required="false" /><br>
    Input 2: <input type="text" required="true" /> *<br>
    Input 3: <input type="text" required="false" /><br>
    Input 4: <input type="text" required="false" /><br>
    Input 5: <input type="text" required="true" /> *<br>
    Input 6: <input type="text" required="false" /><br>
    Input 7: <input type="text" required="true" /> *<br>
    <input type="button" id="subButton" value="Run" />

This is my jQuery-script:

$(document).ready(function(){
                $("#subButton").click(function(){

                    //Copy START
                    var setError = false;
                    $.each($(":input"), function(e){
                        if(($(this).attr("required") == "true") && (this.value == "")){
                            setError = true;
                        }
                    });
                    if(setError != false) alert("Not all required fields are filled");
                    //Copy END

                });
            });

If i change the attr to “type”, it works if i not fill up every box. But i want to use this with the attribute required.

Any ideas, why it doesn’t work?

Thanks for help

  • 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-18T01:17:18+00:00Added an answer on June 18, 2026 at 1:17 am

    You are using required in a wrong way. If HTML, it should be this way:

    <input type="text" required />
    

    And if it is XHTML, it should be this way:

    <input type="text" required="required" />
    

    And you need to access it using jQuery using $.prop():

    if($("input").prop("required")) { ... }
    

    Else, you have the freedom to use data-* attributes this way:

    data-reqd="yes"
    

    And access it using:

    if ($(this).data("reqd") == "yes") { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Absolute beginner question: I have a template file index.html that looks like this: ...
I have an html form that looks something like this: <div class=field> <input id=product_name
I have a form that I want to validate looks like this: <!DOCTYPE html
Say I have a HTML page that looks like this: That was created with
I'm generating an html file which looks like: <tr id=ID001 property1=PROPERTY001><td><input type=checkbox name=row_checkbox_ID001></td><td>...</td><td>...</td></tr> <tr
I have a single .html file that looks similar to the following: <div id=myPage
I have a html file that has invoice details I would like to know
I have an html table that is populated from a text file, formatted and
I have got this button: <input type=button value=Rep id=rep name=rep class=rep style=width:50px onclick=triggerLabel(1);this.disabled=true;addRep(<?php echo
I have a webpage that looks like: <html> <head> <title>Hi</title> </head> <body> <form name=mainForm

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.