用HTML输入三角形的三条边长 然后传参到JS中判断是什么类型的三角形,有等边,等腰,普通三角形

只能为1至100的整数,不能为字母,浮点数,特殊字符等!~谢谢了!~

<html>
<head>
</head>

<body>
边1:
<input name="l1" type="text" id="l1" />
<br>
边2:
<input name="l2" type="text" id="l2" />
<br>
边3:
<input name="l3" type="text" id="l3" />
<br>
<input type="button" name="button" value="判断" onclick="ChkTpye()"/>
<script language="JavaScript" type="text/javascript">
function ChkTpye()
{
var o1 = document.getElementById("l1");
var o2 = document.getElementById("l2");
var o3 = document.getElementById("l3");

var v1 = parseInt(o1.value);
var v2 = parseInt(o2.value);
var v3 = parseInt(o3.value);
if ( isNaN(v1) )
{
alert('边1不是有效数字!')
o1.focus();
return;
}
else
{
if ( v1 <= 0 || v1 > 100 || o1.value.indexOf(".") != -1 )
{
alert('边1输入的数据不正确!')
o1.focus();
return;
}
}
if ( isNaN(v2) )
{
alert('边2不是有效数字!')
o2.focus();
return;
}
else
{
if ( v2 <= 0 || v2 > 100 || o2.value.indexOf(".") != -1 )
{
alert('边2输入的数据不正确!')
o2.focus();
return;
}
}
if ( isNaN(v3) )
{
alert('边3不是有效数字!')
o3.focus();
return;
}
else
{
if ( v3 <= 0 || v3 > 100 || o3.value.indexOf(".") != -1 )
{
alert('边3输入的数据不正确!')
o3.focus();
return;
}
}
if (v1 == v2 && v1 == v3 )
alert("等边三角形")
else if (v1 == v2 || v1 == v3 || v2 == v3 )
alert("等腰三角形")
else
alert("普通三角形")
}
</script>

</body>
</html>
温馨提示:答案为网友推荐,仅供参考