Getting number of characters with Length ? 
Author Message
 Getting number of characters with Length ?

Hi,

I'm trying to get the number of characters from a
string.... It's driving me Nuts! how do you do a thing like
that? I tried the following:

***************************************************************
<Form Name=Form>
<SCRIPT LANGUAGE="JavaScript"><!--
function test(){
 var test = document.Form.text1.value;
 if (test.Length < 4){
  alert("< 4 : " + test.Length)
 }else{
  alert("else : " + test.Length)
 }

Quote:
}

 //-->
</SCRIPT>
<INPUT type="text" id=text1 name=text1>
<INPUT type="button" value="Button" id=button1 name=button1
language="Javascript" onclick="test()">
</Form>
***************************************************************

But all it gives me is "undefined", also I tried:

    test = new String(document.Form.text1.value);

but still it's no good....

HELP!!!!!!

What am I doing wrong?

Any help will be very much appreciated!

Marc (Amsterdam, The Netherlands)

Merry Christmas!!!!



Sun, 09 Jun 2002 03:00:00 GMT  
 Getting number of characters with Length ?
Phew.... I got it!
Length should have been length :-/

I'm used to Visual Basic where functions
or methods can be spelled any way....



Quote:
> Hi,

> I'm trying to get the number of characters from a
> string.... It's driving me Nuts! how do you do a thing like
> that? I tried the following:

> ***************************************************************
> <Form Name=Form>
> <SCRIPT LANGUAGE="JavaScript"><!--
> function test(){
>  var test = document.Form.text1.value;
>  if (test.Length < 4){
>   alert("< 4 : " + test.Length)
>  }else{
>   alert("else : " + test.Length)
>  }
> }
>  file://-->
> </SCRIPT>
> <INPUT type="text" id=text1 name=text1>
> <INPUT type="button" value="Button" id=button1 name=button1
> language="Javascript" onclick="test()">
> </Form>
> ***************************************************************

> But all it gives me is "undefined", also I tried:

>     test = new String(document.Form.text1.value);

> but still it's no good....

> HELP!!!!!!

> What am I doing wrong?

> Any help will be very much appreciated!

> Marc (Amsterdam, The Netherlands)

> Merry Christmas!!!!



Sun, 09 Jun 2002 03:00:00 GMT  
 Getting number of characters with Length ?

Quote:
> I'm used to Visual Basic where functions
> or methods can be spelled any way....

I'm sure that you ment "capitalized any way ...."
I believe that you still need to spell the functions and methods correctly :-)

Vincent Minden

Quote:

> Phew.... I got it!
> Length should have been length :-/

> I'm used to Visual Basic where functions
> or methods can be spelled any way....



> > Hi,

> > I'm trying to get the number of characters from a
> > string.... It's driving me Nuts! how do you do a thing like
> > that? I tried the following:

> > ***************************************************************
> > <Form Name=Form>
> > <SCRIPT LANGUAGE="JavaScript"><!--
> > function test(){
> >  var test = document.Form.text1.value;
> >  if (test.Length < 4){
> >   alert("< 4 : " + test.Length)
> >  }else{
> >   alert("else : " + test.Length)
> >  }
> > }
> >  file://-->
> > </SCRIPT>
> > <INPUT type="text" id=text1 name=text1>
> > <INPUT type="button" value="Button" id=button1 name=button1
> > language="Javascript" onclick="test()">
> > </Form>
> > ***************************************************************

> > But all it gives me is "undefined", also I tried:

> >     test = new String(document.Form.text1.value);

> > but still it's no good....

> > HELP!!!!!!

> > What am I doing wrong?

> > Any help will be very much appreciated!

> > Marc (Amsterdam, The Netherlands)

> > Merry Christmas!!!!



Fri, 14 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Character 15 gets changed to character 12: why?

2. Underlining and character lengths

3. open a text file in VBScript having 500k characters in length and 5GB

4. Array length NOT getting updated when adding elements

5. Counting the number of occurrences of a character...

6. Number of characters in a string

7. Convert character to number

8. What are the maximum number of characters that...

9. Converting a number to a character string

10. Help with How to generate characters from numbers

11. Limit the number of characters entered in a text area

12. count number of characters in a string

 

 
Powered by phpBB® Forum Software