How do I find the string length of a multiline text field?

How do I find the string length of a multiline text field?

I want to limit the max characters in a multliline string and strangely there isn't a standard option. SO how do I do it in code?

I tried

  1.  if(input.mytextfield.length>500) 

but I just get an error.