[英]HTML Form text checked with javascript regular expression
I work on an html form, which I need checked with javascript regex but it is only working if I put in static text. 我使用的是html表单,我需要使用javascript regex进行检查,但是仅当我输入静态文本时它才可以工作。 I need the html form text(input data) to be checked against the regex.
我需要针对正则表达式检查html表单文本(输入数据)。
I have searched for this around, but i can only find people showing examples with static text. 我已经在周围搜索了,但是我只能找到显示带有静态文本示例的人。
Fruther explanation: I don't need help for understanding the regular expressions. 进一步的解释:我不需要帮助来理解正则表达式。 I need to understand how to pass the data, which the user inputs - into the check against the regular expression.
我需要了解如何将用户输入的数据传递到针对正则表达式的检查中。
<script>
function fn() {
var x=document.getElementById("fname");
xv=x.value.toUpperCase();
var re = new RegExp("s", "g"); //Here is the expression i am searching for - This i do understand//
var result = re.test( ?? ); //Here should go the user input from ((("fname" - var x)))
if (result == true) {
var result = $("#result").empty();
$.post('../search.php',{xv : xv},
function(data){
result.append(data);
}
if (result == false) {
var result = $("#result").empty();
result.append("try again");
}
}
</script>
Do you mean: 你的意思是:
var re = new RegExp("s", "g");
**var result = re.test(xv);**
if (result == true) {
}
if (result == false) {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.