前后写的,最主要的可还是正则式哦
其他的也都上框架
1、检测URL类型
<SCRIPT language="javascript">
function checkURLValid()
...{
var urlText = document.getElementById("QTextBoxURL").value;
var regExp=new RegExp("((^http)|(^https))://([/w-]+.)+[/w-]+(/[/w- ./?%&=]*)?"); //please pay attention here / is not
var found = urlText.match(regExp);//method 1
////var found=regExp.exec(urlText); //method 2
if(document.getElementById("QTextBoxLayoutName").value == "" )
...{
alert("Layout name is required!");
return false;
}
if(document.getElementById("QTextBoxURL").value == "" )
...{
alert("URL is required!");
return false;
}
else
...{
if (found == null) //!found
...{
alert("URL format is invalid!");
return false;
}
}
return true;
}
</SCRIPT>
2、1+1替换
<script language="javascript">
function ExpandInfo(controlID)
...{
// alert(controlID.innerText);
// controlID.style ="display:none";
}
function ChangePic(controlID)
...{
if(controlID.alt == "expand")
...{
controlID.src="images/expand.gif";
controlID.alt="collapse";
//handle expand
var changedHTML;
changedHTML = controlID.parentElement.innerHTML;
var regExp = /;/ig;
changedHTML = changedHTML.replace(regExp,"<br>");
alert( controlID.parentElement.innerHTML);
controlID.parentElement.innerHTML = changedHTML;
}
else
...{
controlID.src="images/collapse.gif";
controlID.alt="expand";
//handle expand
var changedHTML;
changedHTML = controlID.parentElement.innerHTML;
var regExp = /<br>/ig;
changedHTML = changedHTML.replace(regExp,";");
alert( controlID.parentElement.innerHTML);
controlID.parentElement.innerHTML = changedHTML;
}
}
</script>
520

被折叠的 条评论
为什么被折叠?



