[英]How to check whether a certain value is entered in a textfield in Java
Does anyone know how to check whether someone entered something in a textfield in java which isn't allowed (depending on my requirements)?有谁知道如何检查是否有人在 java 的文本字段中输入了不允许的内容(取决于我的要求)?
It is my intention that no special characters can be entered, but now it's possible to enter "=true" (according to the function, it then satisfies, because it returns a true).我的意图是不能输入特殊字符,但现在可以输入“=true”(根据 function,它满足,因为它返回 true)。 I've written a function to check whether the username is correct or not.我写了一个 function 来检查用户名是否正确。
I have already solved it.我已经解决了。 I made a string variable that retrieves the entered text and add a trim() and toLowerCase() function.我创建了一个字符串变量来检索输入的文本并添加一个 trim() 和 toLowerCase() function。 Then I check if the entered value is equal to certain values and if it contains some special chars.然后我检查输入的值是否等于某些值以及它是否包含一些特殊字符。 For me it's works well now.对我来说,它现在运作良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.