简体   繁体   中英

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

I want to verify the user input (number) in a textfield that if it's bigger than 9 or not. Note that the number from 1 to 9 . if it's bigger than 9 I want to show a jOptionPane some code i have traied:

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
        }

So how to do that with java? Thanks in advance :)

You can directly do it with help of js using jQuery just give id to our text field and add a script tag with the following code :

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

or any thing else you want to achieve

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM