2017-02-09 17 views
-1

モバイル番号フィールドが空のままになると、送信ボタンをクリックしてアラートが表示されます。パスワードを入力してパスワードを確認すると、パスワードの不一致時にエラーが表示されます。アラートを追加するには?ここで は、登録フォームのコードです:あなたはHTML5をサポートする最新のブラウザを使用している場合入力フィールドが空になるとアラートを表示し、送信ボタンをクリックしてエラーメッセージを表示します

<head> 
</head> 
<body> 
<div class="container"> 
<h2>Login</h2> 
<form> 
<div class="form-group"> 
<label for="mobile number">mobile no:</label> 
<input type="text" class="form-control" id="email" placeholder="Enter mobile number"> 
</div> 
<div class="form-group"> 
    <label for="pwd">Password:</label> 
    <input type="password" class="form-control" id="pwd" placeholder="Enter password"> 
</div> 
<div class="form-group"> 
    <label for="pwd">Password:</label> 
    <input type="password" class="form-control" id="pwd" placeholder="reenter password"> 
</div> 
<div class="form-group"> 
    <label for="pwd">firstname:</label> 
    <input type="text" class="form-control" id="pwd" placeholder="enter first name"> 
</div> 
<div class="form-group"> 
    <label for="pwd">last name::</label> 
    <input type="text" class="form-control" id="pwd" placeholder="enter last name"> 
</div> 
<div class="form-group"> 
<label for="pwd">select city:</label> 

<select name="select city" ><option>mangalore</option><option> mysore</option><option>hubli</option><option>dharvad</option></select> 
</div> 
<div class="form-group"> 
<label for="pwd">select state:</label> 
<select name="select state" placeholder="state"> <option>kerala</option> <option>karnataka</option><option>tamil nadu</option></select> 
</div> 
<button type="submit" class="btn btn-default">Submit</button> 
</form> 
</div> 
</body> 
</html> 
+0

使用可能なjqueryフォームの検証スクリプトがあります –

+0

質問をクリーンアップしてください。スタックオーバーフローはコード作成サービスではありません。私たちは皆、お互いを助けるために時間を費やします。あなたができることは、通常の英語と大文字を使って質問を簡単にすることです。 – thesecretmaster

答えて

0

その後、「必要」属性があまりにも便利かもしれません。それはより簡単な方法です。

関連する問題