开发者

how do i get textfield value then combine with regex

开发者 https://www.devze.com 2023-01-03 07:06 出处:网络
i have this code for get data from textfield: <script type=\"text/javascript\"> var mod=document.getElementById(\"mod\").value;

i have this code for get data from textfield:

<script type="text/javascript">
   var mod=document.getElementById("mod").value;
   ajax(mod);
   function callback() {
   if(ajaxObj(mod) {
                    document.getElementById("divResult").innerHTML=ajaxObj.responseText;
                   });
    };
</script>

this code for show result inside HTML table and the table like:

<tr>
<td><div id="divResult"></div></td>
</tr>

and this one for search character:

<script>
var str="KD-R435MUN2D";
var matches=str.match(/(EE|[EJU]).*(D)/i);
if (matches) {
     var firstletter = matches [1]开发者_如何学运维;
     var secondletter = matches [2];
     var thirdletter = matches [3];
alert(firstletter + secondletter + thirdletter);
}else{
      alert (":(");
}
</script>

how to combine both?please help...


this the answer..

<script type="text/javascript">
$("#mod").val();
var matches=str.match(/(EE|[EJU]).*(D)/i);
if (matches) {
     var firstletter = matches [1];
     var secondletter = matches [2];
     var thirdletter = matches [3];
alert(firstletter + secondletter + thirdletter);
}else{
      alert (":(");
}
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消