簡體   English   中英

如果在另一個文本框中輸入了某些內容,如何使文本框可選?

[英]How can I make a text box is optional if something entered in another text box?

這是我的表格,我必須接受電話號碼或電子郵件、身份證或護照號碼

1

在 js/ajax 中檢查驗證的邏輯是什么?

btnsubmit單擊放置一個條件進行驗證,請查找我的代碼段以獲取更多信息。

 $(".btnsubmit").on("click",function(){ if($(".email").val() == "" && ($(".phone").val() == "" || $(".southafricanid").val() == "") && ($(".passport").val() == "" || $(".birthdate").val() == "")) { alert(); } })
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Email :- <input type ="text" class="email" /><br/> Phone:<input type ="text" class="phone" /> South African ID: <input type ="text" class="southafricanid" /><br/> Passport : <input type ="text" class="passport" /> Birth Date :<input type ="text" class="birthdate" /> <br/> <input type ="button" class="btnsubmit" value="Validate" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM