I am attempting to build a function as to check wether or not wild cards will be used in a search string.
Example.
%name% var search_type = "LIKE"
%name var search_type = "LIKE"
name% var search_type = "LIKE"
name var search_type = "EQUALS"
How can a javascript regex be written to substantiate between the 4 types of examples?
<html>
<head>
<script type="text/javascript">
function test() {
var name = document.getElementById("search").value
}
</script>
</head>
<body>
<input type="text" id="search">
<input onclick="test()" type="submit" value="Submit">
</body>
</html>
Here is a DEMO
Update
The above code will work irrespective of the position of the
%symbol in the text. If you are interested that it should either be at the start OR end OR both, use the below code.DEMO Here