0
@形式が使用され、ラジオボタンがjavascriptで動作していない場合にのみ電子メールIDを検証する必要があります。電子メールの入力テキストに設定type="email"
チェックボックス形式としてラジオボタンを作成するが、そのいずれか私を助けて友人にフォームの検証電子メールIDが機能していません..いずれかの人が私の友人を助けることができます
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert(" First Name must be filled out");
return false;
}
var y = document.forms["myForm"]["lname"].value;
if (y == "") {
alert("Last Name must be filled out");
return false;
}
var z = document.forms["myForm"]["email"].value;
if (z== "") {
alert("Email must be filled out");
return false;
}
var a = document.forms["myForm"]["fpassword"].value;
\t var b = document.forms["myForm"]["lpassword"].value;
if(a!=b){
alert("password must be same!");
return false;
}
var a = document.forms["myForm"]["fpassword"].value;
if (a== "") {
alert("fpassword must be filled out");
return false;
}
var b = document.forms["myForm"]["lpassword"].value;
if (b== "") {
alert("lpasswordmust be filled out");
return false;
}
var c = document.forms["myForm"]["mobile"].value;
if (c==""||isNaN(c) || x<10) {
alert("mobile must be filled out");
return false;
\t \t
}
\t
\t var per=document.getElementById("personal").checked;
var bus=document.getElementById("bussiness").checked;
\t
\t if((per=="")&&(bus==""))
\t {
\t alert("select atleast one option");
\t return false;
\t }
\t return true;
}
\t
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>
Task
</title>
<style>
#i{margin-left:200px;}
h1{text-decoration:underline;
color:#281c0e;}
input[type=password]{width:350px;}
#a{width:350px;}
#b{width:350px;}
input[type=submit]{width:200px;
height:30px;}
#c{margin-left:10px;}
}
</style>
</head>
<body>
<div class="jumbotron">
<h1><b>Create your Google Account</b></h1>
<form name="myForm" action="https://www.google.co.in/"
onsubmit="return validateForm()" method="get">
<div id="i"><b>Name:</b><br>
<input type="text" name="fname" placeholder="First"> <input type="text" id="d" name="lname" placeholder="Last">
<br>
<br>
<b>Choose your Email-id</b>
<br>
<br>
<input id="a" type="text" name="email" placeholder="@gmail.com">
<br>
<br>
<b>Create your Password</b><br>
<input type="password" name="fpassword" placeholder="Password">
<br>
<br>
<b>Confirm your Password</b><br>
<input type="password" name="lpassword" placeholder="Password">
<br>
<br>
<b>Mobile Phone:</b><br>
<input id="b" type="text" name="mobile" placeholder="+91">
<br>
<br>
Account type
<input type="checkbox" id="personal" >Personal
<input type="checkbox" id="bussiness">Bussiness<br><br>
<input type="radio" value="male" name="rad" required> Male
<input type="radio" value="female" name="rad"> Female
<br>
<input type="submit" value="submit"class="btn btn-success" >
</div>
</div>
一般的にはラジオボタンが選択されています(オス/メスなど)、複数の選択肢(趣味など)がある場合はチェックボックスが使用されます。 –