Hello there am having a little problem i am trying to add some validations to this from i made the form using tables however its not being color coded and when submitted its not checking the appropriate validations? any body can spear to look at it please.

<html>
<head>
<title>Book Information</title>
<script language="javascript">
function check_bcode()
{
	var bcode 
	bcode=document.frbookinfo.txtbcode.value
	if(bcode=="") 
	{
		alert("This field is compulsory")
		document.frabookinfo.txtbcode.focus()
	}

// need more code for ICT starting with 

}
function check_name()
{
	var name,namlength 
	name=document.frbookinfo.txtbname.value
	namlength=name.length
	if (namlength >=20) 
	{
		alert("This field should be less than 20 characters")
		document.frbookinfo.txtbname.value=""
		document.frbookinfo.txtbname.focus()
	}
	
	
}
function  check_conditions()
{
	var versions,cat,month,date,isbn,t_price,gvt,n_price
		
		versions=document.frbookinfo.version.focus
		if(versions="") 
		{
			alert("Please select a version")
			return false
		}
		var result,count
		result=true
		
		for(count=0;count<2;count++)
		{
			if(document.frbookinfo.categ.value[count].checked==true	)
			{
				result=true	
				return false
			}
			if(result==false) 
			{
				alert("Please select a category")	
				return false
			}
			if(document.frbookinfo.months.value=="")
			{
				alert("Please select a month")
				return false
			}
				
				var yr,yrlength
				year=document.frbookinfo.txtyear.value
				yrlength=year.length
				if(yrlength>4)
				{
					alert("Please enter a year less than four characters")
					document.frbookinfo.txtyear.value==""
					document.frbookinfo.txtyear.focus
					return false
				}
		////place is number here
		
			if(document.frbookinfo.txttotal<500)
			{
				alert("Please ensure that the total price is greater than 500")
				document.frbookinfo.txttotal.value==""
				document.frbookinfo.txttotal.focus
				
			}
			
		}
		

}
</script>
</head>
<body>
<table width="70" border="1" align="center">
<form name="frbookinfo" method="post" action="addbook.html" onSubmit="return check_conditions()">

  <tr>
  <td>BookCode</td>
    <td ><input name="txtbcode" type="text" maxlength="20" onBlur="check_bcode()"></td>
  </tr>
  <tr>
    <td>BookName </td>
    <td colspan="4"><input name="txtbname" type="text" maxlength=""></td>
  </tr>
  <tr> 
    <td>Description</td>
    <td colspan="4"><textarea name="txtdescription" cols="30" rows="4" onFocus="check_name()"></textarea></td>
  </tr>
  <tr>
    <td>Version</td>
    <td colspan="4"><selectname="version">
    <option value= "V.1"> V.1 </option>
    <option value= "V.2"> V.2 </option>
    <option value= "V.3"> V.3 </option>
    <option value= "V.4"> V.4 </option>
    </select></td>
  </tr>
    <tr>
    <td>Category </td>
       <td><input type="radio" name="categ" value="radio1" id="categ_0">Mystery</td>
	    
		<td><input type="radio" name="categ" value="radio2" id="categ_1">Comedy</td>

    <td><input type="radio" name="categ" value="radio3" id="categ_2">Science</td>
   </tr>
  
  <tr>
    <td>Publish Date </td>
    <td><select name="months">
     <option value="">Month</option>
                              <option value="January" >January</option>
                              <option value="February"  >February</option>
                              <option value="March"  >March</option>
                              <option value="April"  >April</option>
                              <option value="May"  >May</option>
                              <option value="June"  >June</option>
                              <option value="July"  >July</option>
                              <option value="August"  >August</option>
                              <option value="September"  >September</option>
                              <option value="Octocber"  >October</option>
                              <option value="November"  >November</option>
                              <option value="December"  >December</option>
    </select></td>
    
    <td> <select name="date">
    <option value= "">Day</option>
    <option value= "1"> 1</option>
    <option value= "2"> 2</option>
    <option value= "3"> 3</option>
    <option value= "4"> 4</option>
    <option value= "5"> 5</option>
    <option value= "6"> 6</option>
    <option value= "7"> 7</option>
    <option value= "8"> 8</option>
    <option value= "9"> 9</option>
    <option value= "10"> 10</option>
	<option value= "11"> 11</option>
    <option value= "12">12</option>
    <option value= "13"> 13</option>
    <option value= "14"> 14</option>
    <option value= "15"> 15</option>
    <option value= "16"> 16</option>
    <option value= "17"> 17</option>
    <option value= "18"> 18</option>
    <option value= "19"> 19</option>
    <option value= "20"> 20</option>
    <option value= "21"> 21</option>
    <option value= "22"> 22</option>
    <option value= "23"> 23</option>
    <option value= "24"> 24</option>
    <option value= "25"> 25</option>
    <option value= "26"> 26</option>
    <option value= "27"> 27</option>
    <option value= "28"> 28</option>
    <option value= "29"> 29</option>
    <option value= "30"> 30</option>
    <option value= "31"> 31</option>
    </td>
    <td> <input name="txtyear" type="text" maxlength="4"> </td> 
  </tr> 
  
  <tr> 
    <td> ISBN Number</td>
    <td colspan="4"> <input name="isbn" type="text" maxlength="60"> </td>
  </tr> 
  <tr> 
    <td> Total Price </td>
    <td colspan="4"> <input name="txttotal" type="text" maxlength="60"> </td>
  </tr> 
  <tr> 
    <td>GCT</td>
    <td><input name="txtgct" type="text" maxlength="60"> </td>
  </tr> 
  <tr> 
    <td> Net Price</td>
    <td> <input name="txtnet" type="text" maxlength="60"></td>
  </tr> 
  <tr> 
  <td> </td> 
  <td> <input name="addbutton" type="submit" value="Add Book"> </td>
  <td> <input name="clear" type="reset" value="Clear"> </td>
  </tr> 
</form>
</table>

</body>
</html>

You'll have to take some recaps in your code! This is a line-breaking errors and missing semicolon's. I'll point something out that starts on this declaration:

var name,namelength // instead of this >>
var name, namelength;

I'l provide you something useful, please check THIS LINK!.
It's a tool that validates the structural data of your JavaScript! Hope it helps...

hey thanks yall for your help i got it to work nowthe colans weren't the problem either thank anyways

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.