私は学校向けのプログラムを書いていますが、彼は私たちに次のことをしてほしいと言っています: 年齢フィールドに数値以外の入力が行われた場合、警告ボックスに 2 行のメッセージが表示されます:
入力した年齢には数字のみを含める必要があります。再入力してください。
次に : 入力した年齢が 18 歳未満の場合、メッセージを含むボタンの下に追加の段落が表示されます。
And Then : 18 歳以上の場合、スクリプトは、応募者の大学の学位取得に基づいて給与を計算し、表示する必要があります。申請者が学位を取得している場合、給与は申請者の年齢に $1000.00 を掛けて決定されます。学位がなければ、乗数はたったの $600.00 になります。[給与の決定] ボタンが押されると、スクリプトは、下のサンプル図に示すように、計算された給与オファーを含む追加の段落要素を表示します。
年齢フィールドに英字が入力されていないことを確認するために、考えられるすべてのことを試しましたが、機能しないようです。助けてください!
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset= utf-8' />
<title>Form Based JavaScript</title>
<style type = "text/css">
h2 {text-align:left;}
body {background-color:lightblue;}
.input {font-family:"Courier New", Courier, monospace;}
</style>
<script type = "text/javascript">
<!--
function salary() `enter code here`
{
var age;
var degree;
if (age != [0-99]
{
document.writeln( "The age that you entered must contain only numerals. <br /> Please re-enter it.");
else if (age < 18)
document.writeln( " Sorry - you must be 18 or older for this job. <br /> Please reapply in [18 - age] years." );
else if (age >=18)
document.writeln( " You qualify! Salary offer [degree * ] dollars. See our staff for an application" );
}
}
// -->
</script>
<!-- project6.htm Tatiana Saavedra 04/17/2013 -->
</head>
<body>
<h2> Applicant Screening Page </h2>
<hr />
<form id = "myForm" action = "">
<p>Email:<input type = "email" id = "email"></p>
<p>Age:<input type = "number" maxlength="3" size="3" id = "age"></p>
<p><label>Check the box if you hold a college degree: <input type = "checkbox" id = "degree"></label></p>
<br />
<form action="">
<input type="button" value="Determine Salary" onclick="salary()"/>
</form>
</body>
</html>