473,396 Members | 2,016 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,396 software developers and data experts.

How to get the length of text held in a div tag

Hi guys,

I am new to Javascript and I've got a Register form that I need users to fill in. I have a separate script to check whether their username and e-mail addresses have already been used, but I want the submit button to be disabled until all the fields have been filled out and the email and username is valid.

I have a separate div tag for displaying the email and username errors, but they are empty if there is no error. How would I check to see if there is no text inside the div tags.

This is what I have tried but it's clearly not right:

Expand|Select|Wrap|Line Numbers
  1. var DivEmail = document.getElementById('emailcheck')
  2.  
  3.     if(DivEmail.innerText !== null)
  4.         {
  5.             ++count;
  6.         }
The count is for later in the script.

Thanks for your help!
May 1 '12 #1
3 4422
Dormilich
8,658 Expert Mod 8TB
.innerText is an IE-only property and it is never null.
May 1 '12 #2
Expand|Select|Wrap|Line Numbers
  1. <div id="temp_div"> your text.....</div>
  2.  
  3. <script type="text/javascript">
  4. var div_text_length = document.getElementById("temp_div").value.length;
  5.  
  6. alert(div_text_length);
  7.  
  8. </script>
May 1 '12 #3
Dormilich
8,658 Expert Mod 8TB
@Bharat383: nope, that doesn’t work. a <div> is not a form control element.

textContent or innerHTML would work.
May 1 '12 #4

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

Similar topics

0
by: Coco | last post by:
can i transform fixed length text to xml using XSL do i have to first load the text to xml and do the transformation? is there any other way to do it?
13
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS...
2
by: Darin Browne | last post by:
I have to create a fixed length text file and was hoping someone could point me to an example or resources that could help explain how it is done in C#. Thanks.
0
by: pdurbha | last post by:
Hi All, I need to parse a fixed length (0-20, 21-40 etc) text file and validate the content against some business rules. I am thinking of writing a C# program which reads and parses the data in...
0
by: cbianchi | last post by:
Hi, I just received a file with demographic data, almost 1GB of text. The issue is, there are no column delimiters, all the informaton is in one single row. I know where the data of intetest...
0
by: Mic | last post by:
Hi, I just started using Visual Web Developer Express 2005. I need to print a dataset that is populated from a fixed length text file. No problem with this part. So I am trying to use a...
6
by: =?Utf-8?B?VGFydW4=?= | last post by:
Hi, I have to generate a fixed length text file.I have a file formats like fields details as well as its length and position.what actually i have to do that i will get the data from the databas...
6
by: ssharpjr | last post by:
Hi Guys, I'm new to Python (mostly) and I'm wanting to use it for a new project I'm faced with. I have a machine (PLC) that is dumping its test results into a fixed- length text file. I need...
2
by: Edwin.Madari | last post by:
#your thought is right. ======================================================= def sizes2fields(sizes): d = begin = 0 for i in sizes: if begin: end = begin + i else: end = i...
8
by: iheartvba | last post by:
Hi I am using Access 2007 and am trying to export a query to a fixed length text file. I tried using the following code to export the text file: DoCmd.TransferText acExportFixed, , "qryFFRDeFile",...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.