Hello!
There is a form:
var fail = false; var warn = false; //IF FAIL=true function failColor(obj) { "use strict"; $(obj).css("background-color", "#831F21"); } //IF FAIL=false function successColor(obj) { "use strict"; $(obj).css("background-color", "#238822"); } //FOR EMAIL START $("#email").blur(function() { "use strict"; if ($(this).val() !== '') { var mailCheck = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/i; if (mailCheck.test($(this).val())) { successColor($(this)); fail = ""; $("#mailErr").text(fail); } else { failColor($(this)); fail = "Incorrect Email."; $("#mailErr").text(fail); } } else if ($(this).val().length < 1) { failColor($(this)); fail = "Email field is required to be filled!"; $("#mailErr").text(fail); } }); //FOR EMAIL END //FOR NAME START $("#name").blur(function() { "use strict"; if ($(this).val().length <= 4) { failColor($(this)); fail = "Nickname has to be longer than 4 symbols!"; $("#nameErr").text(fail); } else if ($(this).val().length >= 32) { failColor($(this)); fail = "Your nickname should be less than 32 symbols."; $("#nameErr").text(fail); } else { successColor($(this)); fail = ""; $("#nameErr").text(fail); } }); //FOR NAME END //FOR PASSWORD START $("#password").blur(function() { "use strict"; if ($(this).val().length <= 4) { failColor($(this)); fail = "Your password is too short."; $("#passErr").text(fail); } else if ($(this).val().length >= 4 && $(this).val().length <= 7) { $("#password").css("background-color", "#C16516"); warn = "Your password is OK but we suggest to make it a little bit longer."; $("#passErr").text(warn); $("#passErr").css("color", "#C16516"); } else if ($(this).val().length >= 34) { failColor($(this)); fail = "Your password is too long. The length is 4-34 symbols."; $("#passErr").text(fail); } else { successColor($(this)); fail = ""; $("#passErr").text(fail); } }); //FOR PASSWORD END //SUBMIT START $("#register").click(function() { "use strict"; if (fail === false || fail === "") { return true; } else { $("#submissionErr").text("Register failed. Please check the red fields."); return false; } }); //SUBMIT END @charset "UTF-8"; /* CSS Document */ /* Main form */ div.forma { margin: 0; padding: 0; } div.forma h2 { text-align: center; color: #DBD7D7 } .register { width: 70%; margin: 15px auto; border: 3px outset #7A0EB3; background-color: #832ACA; box-shadow: 2px 1px 1px 2px rgba(26, 26, 26, .7); text-align: center; } .register label { width: 94%; margin: 5px auto 5px; display: block; text-align: center; color: #DBDBDB; font-size: 1.1em; } .register input { display: inline; width: 50%; margin: 5px auto 20px; border: 3px outset rgba(137, 20, 167, 1.00); color: #0E2CC6; font-size: 0.99em; font-family: 'Ubuntu Mono', monospace; } .register p { margin: -10px auto 5px; padding: 0; color: #AC0C0F; font-weight: bold; text-align: center; width: 50%; } #register { border: 2px outset #2619A3; background-color: #1709CD; color: #F7EFEF; width: 23%; border-radius: 30% } div.gender { text-align: center; width: 50%; margin: auto; } div.gender input { display: inline; width: auto; margin-right: 3px; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <div class="forma"> <h2> <?php echo $htext?> </h2> <form class="register"> <label>Welcome to registration page! Type in required values into these fields to register.</label><br/> <label for="email">Email</label> <input type="text" name="email" id="email" placeholder="EMAIL" /> <p id="mailErr"></p> <label for="name">Nickname</label> <input type="text" name="name" placeholder="NICKNAME" id="name" /> <p id="nameErr"></p> <label for="gender">Gender</label> <div class="gender"> <b style="float: left; color:#03A9FF"> <input type="radio" name="gender" id="male" value="male"/> <i class="fa fa-male" aria-hidden="true"></i> Male</b> <b style="float: right; color: #D805CD"> <input type="radio" name="gender" id="female" value="female"/> <i class="fa fa-female" aria-hidden="true"></i> Female</b> </div> <br/><br/> <label for="password">Password</label> <input type="password" name="password" placeholder="PASSWORD" id="password" /> <p id="passErr"></p> <input type="submit" id="register" value="Register" name="register" /> <p id="submissionErr"></p> </form> </div> As you can see there is a gender check ( husband, wives ), and I need to turn it on, as a required parameter in the script after the comment //SUBMISSION START , and if the floor is not selected, then //SUBMISSION START something else in the submissionErr field
$("#submissionErr").text("Please select your gender"); Thanks in advance. And even if you find a little "bydlokod" in the script, do not scold too much