473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

validation for a new row added.

hi all .....please help me ...
my problem is i m having a row by default.And validation works fine for this,
But if i add an extra row to it.....even if i enter the values for the new added row i get error that -----i hav not entered the values.
PLease find the solution...Below is the code i hav used.......


[HTML]<%@ page session="true"%>
<html>
<head><title=title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<LINK href="/STYLES/HD_Style.css" type=text/css rel=stylesheet>
<link rel="stylesheet" type="text/css" media="all" href="script/calendar-win2k-cold-1.css" title="win2k-cold-1" />
<link rel="stylesheet" type="text/css" media="all" href="script/common-style.css" title="style1" />
<link rel="shortcut icon" href="favicon.ico"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<script language="JavaScript" src="script/tigra_tables.js"></script>
<script type="text/javascript" src="script/calendar.js"></script>
<script type="text/javascript" src="script/calendar-setup.js"></script>
<script type="text/javascript" src="script/calendar-en.js"></script>
<script language="JavaScript" src="script/validator.js"></script>
<script language="JavaScript" src="script/validations.js"></script>
<style type=text/css>
.blog
{
visibility: visible;
display: block;
background-color:#CCC;
}
.halfmoon{
margin-bottom: 4px;
}
.halfmoon ul{
padding: 3px 9px 2px 5px;
margin-left: 0;
margin-top: 1px;
margin-bottom: 0;
font: bold 14px Verdana;
list-style-type: none;
text-align: left;
border-bottom: 1px solid #929492;
}

.halfmoon li{
display: inline;
margin: 0;
}

.halfmoon li a{
text-decoration: none;
padding: 3px 9px 2px 5px;
margin: 0;
margin-right: 0; /*distance between each tab*/
border-left: 1px solid #DDD;
color: black;
font: bold 14px Verdana;
background: orange url(tabright.gif) top right no-repeat;
}

.halfmoon li a:visited{
color: Red;
}

.halfmoon li a:hover, .halfmoon li a.current{
background-color: orange;
color: blue;
}

#tabcontentcontainer{
width:95%; /*width of 2nd level content*/
height:1.5em; /*height of 2nd level content. Set to largest's content height to avoid jittering.*/
}

.tabcontent{
display:none;
}


</style>[/html]

Expand|Select|Wrap|Line Numbers
  1. <Script language="JavaScript">
  2. row=1;
  3. function Add() {    
  4.         str = document.getElementById("Table1").innerHTML;    
  5.         oldTableData = str.substring(0, str.length-1);
  6.         newTableData = oldTableData +"<tr align='center'>"
  7.         //+"<td><input type=text id=lineseqs name=lineseqs size=3 value="+(row+1)+" ></td>"
  8.         +"<td bgcolor='orange' width='113'><center><input type=text name='N1' size=15></center></td>"
  9.         +"<td  bgcolor='orange' width='113' ><center><input type=text name='N2' size=15></center></td>"
  10.         +"<td  bgcolor='orange' width='113'><center><input type=text name='N3' size=15></center></td>"
  11.         +"<td  bgcolor='orange' width='113'><center><input type=text name='N4' size=15></center></td>"
  12.        +"</tr>"+
  13.         "</table>";
  14.         document.getElementById("Table1").innerHTML = newTableData;
  15.  
  16.     row=row+1;
  17.     out.print(str.length);
  18.     nullValidation();
  19.     delrow_stat();
  20.  
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27. function delrow()
  28. {
  29.     if(confirm("Are you sure you want to Delete")==true) 
  30.     {
  31.     document.getElementById('mytable').deleteRow()
  32.     row=row-1;
  33.     delrow_stat();
  34.     }
  35. }
  36. function delrow_stat()
  37. {
  38. document.getElementById('rows').value=row;
  39. }
  40. function noEdit(){
  41. obj1=document.getElementById('emp_id');
  42. obj2=document.getElementById('fstName');
  43. obj1.contentEditable = false; 
  44. obj2.contentEditable = false; 
  45. delrow_stat();
  46. }
  47. function fnPaste() {
  48. event.returnValue = false;
  49.  
  50. }
  51.  
  52. function fnCopy() {
  53. event.returnValue = false;
  54.  
  55. }
  56. function fnSelect() {
  57. event.returnValue = false;
  58. }
  59.  function goBack()
  60. {
  61. history.back();
  62. }
  63. </script>
  64. <script type="text/javascript">
  65. //function displayrow() {
  66. //alert("hai");
  67. //    //if (!document.getElementsByTagName || !document.createTextNode) return;
  68. //
  69. ////    var rows = document.getElementById('Table1').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
  70. ////document.getElementById('Table1').
  71. //
  72. //    var rows = getElementById('mytable').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
  73. //    for (i = 0; i < rows.length; i++) {
  74. //
  75. //        rows[i].onclick = function() {
  76. //
  77. //            alert(this.rowIndex + 1);
  78. //
  79. //        }
  80. //
  81. //    }
  82. //
  83. //}
  84. //
  85. //</script>
  86.  
  87. </Script>
[html]</head>
<body bgcolor="lightyellow" onLoad="displayrow();">
<p>
<div id="ddimagetabs" style3="margin-bottom: 4px; font-size: 12px;">

<a href="genForm.jsp" color="red">GENERAL</a>
<a href="eduForm.jsp">EDUCATION</a>
<a href="dependForm.jsp">DEPENDENT</a>
<a href="benefitForm.jsp">BENEFITS</a>
<a href="skillForm.jsp">SKILLS</a>
<a href="addEmpID.jsp">ADD/UPDATE</a>

</div>
<form method="POST" name="jobform" action="jobForm.do" onSubmit="return v.exec();">
<br><br>
<font color="blue"><b></b></font>
<table bgcolor=lightyellow cellpadding=2 cellspacing=2 align="left" >
<tr align="center"><td align="center" bgcolor="orange" width=113 >Emp Id</td>
<td bgcolor="orange">
<input type="text" id="emp_id" size="15" name="emp_id" class ="blog"
value=<%=session.getAttribute("sessEmpid")%> onPaste="fnPaste();" onCopy="fnCopy();" onSelect="fnSelect();" ></td>
</tr><tr>
<td align="center" bgcolor="orange" width=113>Employee Name</td>
<td bgcolor="orange">
<input type="text" id="fstName" size=15 class ="blog" name="fstName"
onPaste="fnPaste();" onCopy="fnCopy();" onSelect="fnSelect();" value=<%=session.getAttribute("sessfstName")%>> </td>
</tr>
</table>
<br><br><br><br>
<br clear="left">
<fieldset><legend> <b>Job Info</b> </legend>
<table border="0" width="107%" height="115">
<tr>
<td width="18%" height="1"></td>
<td width="4%" height="1"><br></td>
<td width="17%" height="1"></td>
<td width="27%" height="1"></td>
</tr>
<tr>
<td width="18%" height="33"></td>
<td width="9%" height="33" ><div align="center">Job Type</div></td>
<td width="32%" height="33"><font face="System"> <input
type="radio" value="V3" checked name="R1"> Fulltime<input
type="radio" name="R1" value="V4">Contractor</font></td>
<td width="4%" height="33"></td>
<td width="15%" height="33"></td>
<td width="27%" height="33"></td>
</tr>
<tr>
<td width="18%" height="34"></td>
<td width="9%" height="34" ><div align="center">Date Of Join</div></td>
<td width="32%" height="34"><input type="text" size="16" id="f_date_a" name="T2"></td>
<td width="4%" height="34">&nbsp;</td>
<td width="15%" height="34"></td>
<td width="27%" height="34">&nbsp;</td>
</tr>
<tr>
<td width="18%" height="25"></td>
<td width="9%" height="21" ><div align="center">Job Grade</div></td>
<td width="32%" height="25"><select size="1" name="D1">
<option selected=selected>-Select-</option>
<option value=C1>C1</option>
<option Value=C2>C2</option>
<option Value=C3>C3</option>
<option value=c4>C4</option>
<option value=C5>C5</option>
<option value=C6>C6</option>
</select></td>
<td width="4%" height="25"></td>
<td width="15%" height="25"></td>
<td width="27%" height="25"></td>
</tr>
<tr>
<td width="18%" height="25"></td>
<td width="9%" height="21"><div align="center">Annaul CTC</div></td>
<td width="32%" height="25"><input type="text" size="16" name="T3"></td>
<td width="4%" height="25"></td>
<td width="15%" height="25"></td>
<td width="27%" height="25"></td>
</tr>
</table>
<br>
<br>
<!--fieldset-->
<div align="left"></div>

<font color="red"><b>
<div id="Table1">
<table bgcolor="lightyellow" cellpadding="2" cellspacing="2" width="457"
align="center" id='mytable'>

<tr>
<th bgcolor="orange" width="113">Project</th>
<th bgcolor="orange" width="113">Location</th>
<th bgcolor="orange" width="117">Reports to</th>
<th bgcolor="orange" width="113">Remark</th>
</tr>
<tbody>
<tr>
<td bgcolor="orange" width="113"><font color="red"><b>
<input type=text name="N1" size="15"></b></font></td>
<td bgcolor="orange" width="113">
<center><input type=text name="N2" size="15"></center>
</td>
<td bgcolor="orange" width="117"><font color="red"><b>
<input type=text name="N3" size="15"></b></font></td>
<td bgcolor="orange" width="113">
<center><input type=text name="N4" size="15"></center>
</td>
</tr>
</tbody>
</table>
</div><br>
<center>
<INPUT id="Button1" style="color:darkorange;font:bold;background:white " type="button" value="AddRow" name="Button1" onClick="Add()" >
<INPUT id="Button2" style="color:darkorange;font:bold;background:white " type="button" value="DelRow" name="Button2" onClick="delrow();">
<input type="submit" name="submit" value="SUBMIT"
style="color:darkorange;font:bold;background:white ">
<input type="reset" name="reset" value="RESET"
style="color:darkorange;font:bold;background:white ">
<input type="button" value="<< BACK" title="Previous Page" onClick="goBack();" style="color:darkorange;font:bold;background:white " >
<input type="hidden" name="hiddeval"></center><!--/fieldset-->
<!--/fieldset-->
<input type="hidden" name="emp_id" value=<%=session.getAttribute("sessEmpid")%>>
<input type="hidden" name="rows" id="rows" value="0">
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="2"
height="249">
<tr>
<td class="dataHeader_other" align="center" height="245"></td>
</tr>
</table>
<script type="text/javascript">


Calendar.setup({
inputField : "f_date_a", // id of the input field
ifFormat : "%y-%m-%d ", // format of the input field
showsTime : true,
timeFormat : "24"
});


var a_fields = {

'T2':{'l':'Date of Join','r':true},
'T3':{'l':'Annual CTC','r':true,'f':'integer'},
'D1':{'l':'Job Grade','r':true},
'N1':{'l':'Project','r':true,'f':'alpha'},
'N2':{'l':'Location','r':true,'f':'alpha'},
'N3':{'l':'Report','r':true,'f':'alpha'},
'N4':{'l':'Remark','r':true,'f':'alpha'}
},
o_config = {
'to_disable' : ['submit','reset'],
'alert' : 1
}
// validator constructor call
var v = new validator('jobform', a_fields, o_config);

</script>
</title></body>
</html>[/HTML]
Jul 10 '07 #1
3 2127
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

You're adding the row at the end of the table tag and you don't have a beginning tbody tag.
Jul 10 '07 #2
I hav tried fir this but the new row now added comes in different way...n validation still does not work.
Jul 11 '07 #3
acoder
16,027 Expert Mod 8TB
See this example It shows how to add a row and how to validate.
Jul 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
3
by: Gary Varga | last post by:
In the file WebUIValidation.js, when a postback that doesn't fail the validation has a javascript error saying summary is undefined in the ValidationSummaryOnSubmit function....
2
by: Fourge | last post by:
Hi, I have run into a very strange scenario. In developing an ASP.NET application on framework version 1.1, I found that certain client-side validation scripts were not being rendered. The...
4
by: Alan Silver | last post by:
Hello, I have been playing with some of the code in ASP.NET Unleashed, to try and understand what's going on. I am getting on pretty well, but have struck a problem. I was looking at samples for...
8
by: John Dalberg | last post by:
I have an aspx page that was developed initially in Dreamweaver as a regular html file. I have added a few textboxes and required validators. The problem is that the client side validation is not...
1
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that...
1
by: vidya | last post by:
Hi, I have a button which is a web control. I have some validation in javascript for the button in .aspx file and some in the button onclick event in code behind(C#). I need to get through both...
0
by: Jack | last post by:
Hi, I got a ASP page where one can add a record or update any existing records. As soon as a record is added it is appended to the existing records. With this design user can check for erors in...
6
by: sck10 | last post by:
Hello, I have applications that produce the following error when they have been open to long without activity. Is there any way to force a re-load of the page or go to another page if the page...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.