开发者

how do i get textfield value then combine with regex

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜