I work on an html form, which I need checked with javascript regex but it is only working if I put in static text. I need the html form text(input data) to be checked against the regex.
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) {
}
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.