gpt4 book ai didi

java - 如何验证文本字段中的用户输入以将其与变量进行比较?

转载 作者:太空宇宙 更新时间:2023-11-04 14:20:19 25 4
gpt4 key购买 nike

我想验证文本字段中的用户输入(数字)是否大于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 在 js 的帮助下直接完成此操作,只需为我们的文本字段提供 id 并使用以下代码添加脚本标签:

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

或者任何你想要实现的目标

关于java - 如何验证文本字段中的用户输入以将其与变量进行比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27270747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com