ラジオボタンの選択項目とテキスト入力項目が2つあります。
各項目が入力されると各送信ボタンが押せるようになりますが、
3つある送信ボタンのうち2個を無くし、1つにして、
ラジオボタン、テキスト入力2つをすべて入力すると
送信ボタンが押せる、というふうにしたいのですが
どのようにすればよろしいでしょうか。
下記ソースには記載していませんが、
一度、lengthのある部分に||を入れて各項目の入力エリアを追記したのですが
うまくいかず困っています。
ご教授いただけませんでしょうか。
html
1<p> 2 <input type="radio" class="demo1" name="demo1" id="demo1-1" autocomplete="off"> 3 <label for="demo1-1">デモ1</label><br> 4 <input type="radio" class="demo1" name="demo1" id="demo1-2" autocomplete="off"> 5 <label for="demo1-2">デモ2</label><br> 6 <input type="radio" class="demo1" name="demo1" id="demo1-3" autocomplete="off"> 7 <label for="demo1-3">デモ3</label> 8</p> 9<p id="link1">ーー</p> 10 11<p> 12 <input type="text" id="input1" autocomplete="off"> 13 <input type="submit" id="submit1" value="送信"> 14</p> 15 16<p> 17 <textarea name="text2" id="text2" autocomplete="off"></textarea> 18 <input type="submit" id="submit2" value="送信"> 19</p>
js
1$(function(){ 2 $(".demo1").click(function(){ 3 if(this.checked){ 4 $("#link1").html("<a href='#'>送信</a>"); 5 } else { 6 $("#link1").html("Next"); 7 }; 8 }); 9}); 10 11$(function(){ 12 if ($("#input1").val().length == 0) { 13 $("#submit1").prop("disabled", true); 14 } 15 $("#input1").on("keydown keyup keypress change", function() { 16 if ($(this).val().length < 2) { 17 $("#submit1").prop("disabled", true); 18 } else { 19 $("#submit1").prop("disabled", false); 20 } 21 }); 22}); 23 24$(function(){ 25 if ($("#text2").val().length == 0) { 26 $("#submit2").prop("disabled", true); 27 } 28 $("#text2").on("keydown keyup keypress change", function() { 29 if ($(this).val().length < 5) { 30 $("#submit2").prop("disabled", true); 31 } else { 32 $("#submit2").prop("disabled", false); 33 } 34 }); 35});
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/15 23:15