0
<html>
<head>
<title>Insert New Student</title>
</head>
<script language ="javascript" type="text/javascript">
    function checkForm(formobj)
    {
          //name
          var formOK = true;
          if (formobj.name.value == "") 
          {
              window.alert("You have to enter value for name.");
              formobj.focus();
              formOK = false;
          }
          //surname
          if (formobj.surname.value == "") 
          {
              window.alert("You have to enter a value for surname.");
              formobj.focus();
              formOK = false;
          }
          //identity number (presence)
          if (formobj.ID.value == "") 
          {
              window.alert("You have to enter an identity number with strictly nine (9) digits.");
              formobj.focus();
              formOK = false;
          }




          //identity number(length)
          if (formobj.ID.length != 9) 
          {
              window.alert("The ID number has to have nine (9) values.");
              formobj.focus();
              formOK = false;
          }


   return formOK;
    }


</script>
<body bgcolor ="aqua" >
<form name = "register" method = "post" action = "Insert New Student.php" onsubmit="return checkForm(this)";/>

<img src = "logo.jpg" 
    style="width: 1095px; height: 214px; margin-left: 128px;" />

<table border = "4" align = "right" bordercolor = "yellow" 
    style="margin-left: 0px; height: 185px; margin-top: 0px;" 
    bgcolor="#C00000">

<tr>
<td align = "center">Faculty</td>
<td><select name = "faculty" 
        style="background-color: #FFFF00; height: 172px; margin-top: 4px; width: 295px;"/>
        <option value = "Information and Communication Technology"/> Information and Communication Technology
        <option value = "Design and Innovation"/> Design and Innovation
        <option value = "Multimedia Creativity"/> Multimedia Creativity
        <option value = "Communication, Media and Broadcasting"/>Communication, Media and Broadcasting 
        <option value = "Architecture and The Build Environment"/>Architecture and The Build Environment
        <option value= "Business Management and Globalisation"/>Business Management and Globalisation
</td>
       </select>
</tr>
<tr>
<td align = "center"> Class</td>
<td><select name = "class" style="background-color: #FFFF00; width: 93px;"/>
       <option value = "BSEM1"/>BSEM
       <option value ="BBIT"/>BBIT
       <option value ="ADSEM"/>ADSEM
</td>
       </select>
</tr>
<tr>
<td align = "center"> Programme</td>
<td><select name = "programme" style="background-color:#FFFF00; width: 331px;"/>
       <option value = "BA(Hons) in Fashion & Retail"/>BA(Hons) in Fashion & Retail
       <option value = "BA(Hons) in Brand & Package Design"/>  BA(Hons) in Brand & Package Design
       <option value = "BA(Hons) in Industrial  Design"/>  BA(Hons) in Industrial Design
       <option value = "BA(Hons) in Profesional Design (Visual Communication)"/>  BA(Hons) in Professional Design(Visual Communication)
       <option value = "BA(Hons) in Creative Multimedia"/>  BA(Hons) in Creative Multimedia
       <option value = "BA(Hons) in Animation"/>  BA(Hons) in Animation
       <option value = "BA(Hons) in Intergrated & Immersive Multimedia"/>  BA(Hons) in Intergrated & Immersive Multimedia
       <option value = "BA(Hons) in Digital Communiation Design"/>  BA(Hons) in Digital Communication Design
       <option value = "BA(Hons) in Digital Imaging & Design"/>  BA(Hons) in Digital Imaging & Design
       <option value = "BA(Hons) in Professional Communication"/>  BA(Hons) in Proffesional Communication
       <option value = "BA(Hons) in Evemt Management"/>  BA(Hons) in Event Management
       <option value = "BA(Hons) in Digital Film & Television"/>  BA(Hons) in Digital Film & Television
       <option value = "BA(Hons) in Broadcasting & Journalism"/>  BA(Hons) in Broadcasting & Journalism
       <option value = "BA(Hons) in Sport Journalism"/>  BA(Hons) in Sport Journalism
       <option value = "BA in Built Environment"/> BA in Built Environment
       <option value = "BA in Interior Architecture"/>  BA in Interior Architecture
       <option value = "Bachelor in Accounting"/>  Bachelor in Accounting
       <option value = "Bachelor in Entrepreneurship"/>  Bachelor in Entrepreneurship
       <option value = "Bachelor in Marketing"/>  Bachelor in Marketing
       <option value = "Bachelor in Accounting"/>  Bachelor in Accounting
       <option value = "BA(Hons) in Tourism Management"/>  BA(Hons) in Tourism Management
       <option value = "BA(Hons) in Public Management"/>  BA(Hons) in Public Management
       <option value = "BA(Hons) in Sport, Health & Fitness Management"/>  BA(Hons) in Sports, Health & Fitness Management
       <option value = "BSc(Hons) in Gaming Technology"/>  BSc(Hons) in Gaming Technology
       <option value = "BSc(Hons) in Mobile Computing"/>  BSC(Hons) in Mobile Computing
       <option value = "BSc(Hons) in Business Information Technology"/>  BSc(Hons) in Business Information Technology
       <option value = "BSc(Hons) in Sport Journalism"/>  BSc(Hons) in Electronic Commerce
       <option value = "BSc(Hons) in Information Technology"/>  BSc(Hons) in Information Technology
       <option value = "BSc(Hons) in Software Development with Multimedia"/>  BSc(Hons) in Software Development with Multimedia


</td>
   </select>
</tr>
<tr>
<td align = "center" class="style1">Registration</td>
<td class="style2"><input type = "radio"  name = "registration" value = "Registered"/> Registered 
                   <input type = "radio"  name = "registration" value = "Not Registered"/>Not Registered</td>

</tr>
</table>

<table border = "4" align = "left" bordercolor = "Yellow" 
    style="height: 185px; width: 440px;" bgcolor="#C00000">
<tr>
<td align = "center"> Surname</td>
<td class="style2">
    <input type = "text"  name = "surname"  value ="" size = "20" 
        style="width: 280px; background-color: #FFFF00" ></td>
</tr>


<tr>
<td align = "center" class="style1"> Name</td>
<td class="style2">
    <input type = "text"  name = "name"  value ="" size = "20" 
        style="width: 280px; background-color: #FFFF00"/></td>
</tr>

<tr>
<td align = "center"> ID</td>
<td class="style2">
    <input type = "text"  name = "ID"  value ="" size = "20" 
        style="width: 280px; background-color: #FFFF00"/></td>
</tr>

<tr>
<td align = "center" class="style4">Gender</td>
<td class="style5"><input type = "radio"  name = "gender" value = "Male"/> Male 
       <input type = "radio"  name = "gender" value = "Female"/>Female</td>
</tr>
</table>
<p align ="center">
<input type= "submit" value = "SUBMIT" 
        style="width: 160px; color: #FFFF00; font-weight: bolder; background-color: #FF00FF; background-repeat: repeat; font-family: 'Adobe Fan Heiti Std B'; text-decoration: blink; font-style: italic; font-size: 20px; margin-top: 0px; height: 39px;"/>
<input type= "reset" value = "RESET" 
        style="width: 160px; color: #FFFF00; font-weight: bolder; background-color: #FF00FF; background-repeat: repeat; font-family: 'Adobe Fan Heiti Std B'; text-decoration: blink; font-style: italic; font-size: 20px; margin-top: 0px; height: 38px;"/> <br />
<a href = "index.html"><i>back</i> </a>
</p>
</form>

</body>
</html>

please help me with a function that will check if all the characters entered for ID are integers.

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by hielo
0
<script type="text/javascript">
function trim(str){
	return String(str).replace(/^\s+|\s+$/g,'');
}
function checkForm(formobj)
{
	//name
	var formOK = true;
	
	if (formobj.name.value == "") 
	{
		window.alert("You have to enter value for name.");
		formobj.focus();
	formOK = false;
	}

	//surname
	if (formobj.surname.value == "") 
	{
		window.alert("You have to enter a value for surname.");
		formobj.focus();
		formOK = false;
	}

	//identity number (presence)
	formobj.ID.value=trim(formobj.ID.value);
	if (false==/^\d{9}$/.test(formobj.ID.value) ) 
	{
		window.alert("You have to enter an identity number with strictly nine (9) digits.");
		formobj.focus();
		formOK = false;
	}

	/*
	The above check makes sure the value of ID is EXACTLY 9 digits
	//identity number(length)
	if (formobj.ID.length != 9) 
	{
		window.alert("The ID number has to have nine (9) values.");
		formobj.focus();
		formOK = false;
	}
	*/
return formOK;
}
</script>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.