Home javascript Required Field for Form

Required Field for Form

Author

Date

Category

It is necessary to make a mandatory country selection. Used in the SELECT tag, the Required attribute – did not help. Added Required = “True” similarly did not help. Thank you.

Field for shape:

& lt; div class = "form-group row" & gt;
          & lt; div class = "col-12" & gt;
            & lt; select class = "Form-Control" name = "Country_id" Required = "True" & gt;
              & lt; optional = "0" & ​​gt; Country & LT; / Option & gt;
              & lt;? php
              $ Data = Array ('is_active' = & gt; 1);
              $ Result_country = $ dbh- & gt; prepare ("Select * from". DB_PREFIX. "COUNTRY WHERE IS_ACTIVE =: IS_ACTIVE");
              $ Result_country- & gt; execute ($ DATA);
              $ Result_country- & gt; setfetchmode (pdo :: fetch_assoc);
              While ($ row_country = $ result_country- & gt; fetch ()) {? & gt;
                & lt; optional = "& lt;? php echo $ row_country ['id']? & gt;" & lt;? php echo $ row_country ['id'] == $ Row ['Country_id']? 'selected': ''; ? & gt; & gt; & lt;? php echo $ row_country ['name']? & gt; & lt; / option & gt;
              & lt;? php}? & gt;
            & lt; / select & gt;
          & lt; / div & gt;
        & lt; / div & gt;

Answer 1, Authority 100%

Because not filled it is an empty string, and not “0”

Change Value on “”

& lt; select class = "Form-Control" name = "circum_id" request = "required" & gt;
 & lt; optional = "" & gt; Country & lt; / Option & gt;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions