日期:2014-05-16 浏览次数:20384 次
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
</head>
<body>
<div class="box">
<textarea id="textarea"></textarea><input type="button" id="butn" value="提交" />
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#butn").click(function(){
var text = $.trim($('#textarea').val());
var textArr = text.split('\n');
if(textArr.length > 20 ){
alert('您输入的条数大于20条');
}else{
var re = /^[TAGCU]{5,30}$/i;
for(var i =1;i<textArr.length;i++){
if(!re.test(textArr[i])){
alert("第"+(i+1)+"行输入格式有误");
}
}
}
})
})
</script>
</body></html>
var $a = ">hsa-let-7b \r\nTGAGGTAGTAGGTTGTGTGGTT \r\n>hsa-let-7b \r\nTTTGAGGTAGTT \r\n>hsa-let-7b \r\nGGAGGTAGTAGGTTGTGTGGTT";
var $b = ">hsa-let-7b \r\nTGAGGTAGTAGGTTGTGTGGTT \r\nhsa-let-7b \r\nTTTGAGGTAGTT \r\n>hsa-let-7b \r\nGGAGGTAGTAGGTTGTGTGGTT";
var $c = ">hsa-let-7b \r\nTGAGGTAGTAGGTTGTGTGGTT \r\n>hsa-let-7b \r\nTyTGAGGTAGTT \r\n>hsa-let-7b \r\nGGAGGTAGTAGGTTGTGTGGTT";
var $r = /^>[^\r\n]*\r\n[TAGCUtagcut]{5,30}\s*\r?$/mg;
var count=0;
var s = -1;
var flag = true;
while (match = $r.exec($a))
{
s += (match[0].length+1);
var $rr = $r.lastIndex;
if(s != $rr){
flag = false;
break;
}
count++;
if(count>20){
flag = false;
break;
}
}
if(!flag){
alert('error');
}