# How can I get Max Lenght of a Text Field

**URL:** <https://www.ruby-forum.com/t/how-can-i-get-max-lenght-of-a-text-field/127859>\
**Category:** Ruby\
**Created:** [February 1, 2008, 9:34pm UTC](https://www.ruby-forum.com/t/how-can-i-get-max-lenght-of-a-text-field/127859 "2008-02-01T21:34:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddad01](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/919ad9/32.png) [@ddad01](https://www.ruby-forum.com/u/ddad01)\
**Post date:** [February 1, 2008, 9:34pm UTC](https://www.ruby-forum.com/t/how-can-i-get-max-lenght-of-a-text-field/127859/1 "2008-02-01T21:34:42Z")

</div>

Blah = $ie.text\_field(:name,$developer\_name).MaxLenght()  
puts Blah

Thanks,

---

<div class="post-metadata">

**Author:** ![ddad01](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/919ad9/32.png) [@ddad01](https://www.ruby-forum.com/u/ddad01)\
**Post date:** [February 1, 2008, 9:43pm UTC](https://www.ruby-forum.com/t/how-can-i-get-max-lenght-of-a-text-field/127859/2 "2008-02-01T21:43:28Z")

</div>

Darin D. wrote:

> Blah = $ie.text\_field(:name,$developer\_name).MaxLenght()  
> puts Blah
> 
> Thanks,

You so close.

First spell Length correctly (“Lenght”)  
Next it should be maxLenght() instead of MaxLenght

Hope that help, dummy.

---

<div class="post-metadata">

**Author:** ![ddad01](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/919ad9/32.png) [@ddad01](https://www.ruby-forum.com/u/ddad01)\
**Post date:** [February 2, 2008, 7:44am UTC](https://www.ruby-forum.com/t/how-can-i-get-max-lenght-of-a-text-field/127859/3 "2008-02-02T07:44:40Z")

</div>

Try this:

a = %w(cat mule tiger vulture)  
puts a.max {|a, b| a.length \<=\> b.length}

=\> vulture
