473,395 Members | 1,629 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,395 software developers and data experts.

need to display error msg in a divtag under tr tag

Hi,
i have a following form.
Expand|Select|Wrap|Line Numbers
  1.     <form id="frm_signup">
  2.     <b>please fill the following registration form.All the fields are compulsory</b><br/><br/>
  3.  
  4.         <table border="0" cellpadding="" cellspacing="" id="register-table"> 
  5.  
  6.         <tr> 
  7.         <td >Username</td><td>:<span style="color:#FF0066">*</span></td> 
  8.         <td id="username_row" ><input type=text id="username" name="username" value="" /> 
  9.         <div class="er_msg"></div></td> 
  10.         </tr> 
  11.  
  12.         <tr> 
  13.         <td >Password</td><td>:<span style="color:#FF0066">*</span></td> 
  14.         <td id="pword_row" ><input type="password" id="pword" name="pword" value="" /> 
  15.         <div class="er_msg"></div></td></tr> 
  16. </table>
  17. <input type="button" id="onRegister" onclick="onRegister()"/>
  18. </form>
  19.  
during validation if username field is empty i want to display error msg in the
div tag corresponding to username row.

so how can i display the msg in username's div tag.

if i use document.getElementById, then the same msg will display for username and password and whereever the div tag appears.

i don't want to use seperate id for each div for each input field.

i got this piece of code from www.adbrite.com sites registration form(under advertisers tab, while asking personal details).

i think the following piece of code can apply to my problem
Expand|Select|Wrap|Line Numbers
  1. function onRegister()
  2. {
  3. MYTABLE=document.getElementById('register-table');
  4. for (i=0;i<MYTABLE.rows.length;i++) {
  5.  
  6. //MYTABLE.rows[i].div.innerHTML="enter value";
  7. alert(MYTABLE.rows[i]);
  8. }
  9.  
can any one think on those lines


can anyone help me pls....
Nov 18 '08 #1
2 3080
RamananKalirajan
608 512MB
u can use this for time being

[HTML]<html>
<head>
<style type="text/css">
.er_msg{
color: #FF0000;
font-size:12px;
font-family: times;
}
</style>
<script type="text/javascript">
function doRegister()
{
//alert("Coming Inside");
if(document.getElementById('username').value=="")
{
document.getElementById('username_row').innerHTML+ ='<div class="er_msg">Please Enter User Name</div>';
return false;
}
if(document.getElementById('pword').value=="")
{
document.getElementById('pword_row').innerHTML+='< div class="er_msg">Please Enter Password</div>';
return false;
}
return true;
}
</script>
</head>
<body>
<form id="frm_signup">
<b>please fill the following registration form.All the fields are compulsory</b><br/><br/>

<table border="0" cellpadding="" cellspacing="" id="register-table">

<tr>
<td >Username</td><td>:<span style="color:#FF0066">*</span></td>
<td id="username_row" ><input type="text" id="username" name="username" value="" /></td>
</tr>

<tr>
<td >Password</td><td>:<span style="color:#FF0066">*</span></td>
<td id="pword_row" ><input type="password" id="pword" name="pword" value="" />
<div class="er_msg"></div> </td>
</tr>
</table>
<input type="button" value="validate Form" onclick="return doRegister();">
</form>
</body>
</html>[/HTML]
Nov 18 '08 #2
acoder
16,027 Expert Mod 8TB
I think that's the very thing which kummu4help wanted to avoid.

Use parentNode to get to the <td> element from the input element and then from there, you can use td.getElementsByTagName("div")[0] to get the div element for displaying the error message.
Nov 18 '08 #3

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

Similar topics

5
by: Thomas Hoheneder | last post by:
Hello, I have a web page that contains the following things. 1) Lots of text, so that the page is longer/higher than one browser screen. 2) Within that text there is an input text field. 3) On...
8
by: Dinesh Jain | last post by:
Hi al,, I have written a code which displays directory listing of files from FTP server directory.I display all the files in a listview with its associated icons. To display icons, I get the...
2
by: Sandy | last post by:
Hello Is there a way in a web form to display a MessageBox? I am not getting Intellisense when I type the word in Any suggestions Sandy
2
by: c676228 | last post by:
Hi, I have several user controls like email, phone,ssn etc. each has it's own validation message in its user control already. When I bring all those user controls in an aspx page, I would like to...
2
by: seberino | last post by:
Why can't I import gtk (pygtk) module? It appears gtk module want X perms? >>> import gtk Traceback (most recent call last): File "<stdin>", line 1, in ? File...
1
by: ewart strain | last post by:
Hello all, I have a form thats tied to my access database and all seems to work well except for one small thing. Info on the code: whenever a consultant contract ends they get moved to an...
5
by: Keflavich | last post by:
Hey, I have a bit of code that died on a domain error when doing an arcsin, and apparently it's because floating point subtraction is having problems. I know about the impossibility of storing...
2
by: jay123 | last post by:
Hello, I am making a project in VS2008, C#. Background of prob: I have integrated a postcode(UK- its like if someone enters postcode and clicks button to retrieve the address, he gets all the...
0
by: Helena Tran | last post by:
I'm doing a dropdown-menu, and combine JS. It's display well in all browser, but it has an error when displaying in IE 7,8 browser: Menu dropdown in normal : ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.