簡體   English   中英

如何驗證文本字段中的用戶輸入以將其與變量進行比較?

[英]How to verify the user input in a textfield to compare it with a variable?

我想驗證textfield中的用戶輸入(數字)是否大於9 請注意,數字從19 如果它大於9我想向jOptionPane顯示一些我已經講過的代碼:

else
        if(jTextField1.contains()){ // want to compare it if it's bigger than 9 or not

            jOptionPane1.showMessageDialog(this,"Please enter the number of the tab"); // wich means from 1 to 9
        }

那么如何用Java做到這一點呢? 提前致謝 :)

您可以直接在jQuery的幫助下使用jQuery做到這一點,只需將id賦予我們的文本字段並使用以下代碼添加腳本標簽即可:

num = $("#yourId").val();
if(num>9){
alert("your message");
}

或您想要實現的任何其他目的

暫無
暫無

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

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