2012-08-03 6 views
1

안녕하세요, 나이가 들지 않아서 자바를 완성하지 못했고 배운 것을 잃어 버렸습니다.양식 데이터가 유효하지 않음

확인하려고 개인 최고는 sellected되었으며 값은 밖으로 내 머리를 당겨 당신에게 나는 그래서 난 다음 다른 값을 코딩 할 수 있습니다 잘못 가고 어디 말해 줄 수 사람을 갔네 1000

1 내에 있는지 자기.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
<meta content="en-gb" http-equiv="Content-Language" /> 
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
<title>Untitled 1</title> 
<style type="text/css"> 
.auto-style1 { 
    width: 84%; 
    height: 156px; 
} 
.auto-style3 { 
    width: 286px; 
} 
.auto-style4 { 
    width: 151px; 
} 
.auto-style5 { 
    width: 123px; 
} 
</style> 
<script type='text/javascript'> 
function valueNumeric(){ 
var valueResult 
var valuetaId=document.forms["myForm"]["Value"].value; 
    var numericExpression = /^[0-9]+$/; 
    if(valuetaId.match(numericExpression)) 
     { 
     valuetaId = parseFloat(valuetaId) 
     if((valuetaId >= 1) ||(valuetaId <= 1000)) 
      { 
      valueResult = ("Valid"); 
      document.getElementById("vl").innerHTML=valueResult;   } 
     else 
      { 
      valueResult = ("Please enter calue between 1 and 1000"); 
      document.getElementById("vl").innerHTML=valueResult; 
      } 
    }else{ 
     valueResult = ("Please enter calue between 1 and 1000"); 
     document.getElementById("vl").innerHTML=valueResult; 
    } 
} 
function personalbest(selection) 
{ 
var rundataResult; 
var rundataId=document.forms["myForm"]["personalbest"].value; 
    if(rundataId == "Please Choose") 
    { 
    rundataResult = ("Please choose a value."); 
    document.getElementById("pb").innerHTML=rundataResult; 
    } 
else{ 
    rundataResult = ("valid"); 
    document.getElementById("pb").innerHTML=rundataResult; 
    } 
} 
</script> 
</head> 

<body> 

<form name="myForm" action="" method="post"> 
    <br /> 
    <table class="auto-style1"> 
     <tr> 
      <td class="auto-style4">Value 1 to 1000</td> 
      <td class="auto-style5"><input name="Value" type="text" onblur="valueNumeric" /></td> 
      <td class="auto-style3"> 
      <p id="vl">Please enter calue between 1 and 1000</p> 
      </td> 
     </tr> 
     <tr> 
      <td class="auto-style4">Date YY-MM-DD</td> 
      <td class="auto-style5"><input name="Date" type="text" /></td> 
      <td class="auto-style3"> 
      <p>Please enter a date.</p> 
      </td> 
     </tr> 
     <tr> 
      <td class="auto-style4">Time HH-MM-SS</td> 
      <td class="auto-style5"><input name="Timme" type="text" /></td> 
      <td class="auto-style3"> 
      <p>Please enter your time.</p> 
      </td> 
     </tr> 
     <tr> 
      <td class="auto-style4">Grade % i.e. 74.56</td> 
      <td class="auto-style5"><input name="Grade" type="text" /></td> 
      <td class="auto-style3"> 
      <p style="width: 394px">Pease enter your grade as a % with 2 decimal 
      places</p> 
      </td> 
     </tr> 
     <tr> 
      <td class="auto-style4">Personal Best</td> 
      <td class="auto-style5"><select name="personalbest" onchange="personalbest('selection')"> 
      <option selected="selected">Please Choose</option> 
      <option value="1">Yes</option> 
      <option value="0">No</option> 
      </select></td> 
      <td class="auto-style3"> 
      <p id="pb">Please choose a value.</p> 
      </td> 
     </tr> 
    </table> 
</form> 

</body> 

</html> 
+2

java! = javascript – Hamish

답변

1

당신은 통지 전화를 valueNumeric 사용 onblur="valueNumeric()"를 호출하지 않았다 또한 ()

if((valuetaId >= 1) ||(valuetaId <= 1000))

도가 1 ~ 1000의 값에 대한 진정한 평가 범위 if((valuetaId >= 1) && (valuetaId <= 1000))를 사용합니다 personalbest 요소 이름과 함수와 충돌하므로 함수 이름을 personalBest

로 변경하십시오.

관련 문제