
20.07.2007, 11:56
|
|
Участник форума
Регистрация: 19.05.2007
Сообщений: 228
Провел на форуме: 4325663
Репутация:
240
|
|
Юзай регулярные выражения
Код:
<html>
<head>
<script>
<!--
function Go_Tour(){
res=/^(-?)(\d*)$/.test(document.MyForm.Enter.value);
if (res==false) {
res=/^(\d*).(\d*)$/.test(document.MyForm.Enter.value);
if (res==true) {alert("Введите целое значение!")}
if (res==false) {alert("Введите целое число!")}
}
if (document.MyForm.Enter.value<0) alert("Введите положытельное число!");
}
//-->
</script>
</head>
<body>
<form name="MyForm">
<table cellpadding=5 cellspacing=0 border=0 bgcolor="#CAD8EA">
<tr>
<td colspan=2>
Число:
</td>
</tr>
<tr>
<td>
<input name=Enter type=text size=20>
</td>
<td>
<input type="button" Value=">>" onClick="Go_Tour();">
</td>
</tr>
</table>
</form>
</body>
</html>
|
|
|