How do i limit the charlength for a input field?

How do i limit the charlength for a input field?

GeXXGeXX Posts: 3Questions: 0Answers: 0
edited August 2012 in Editor
Hi,

i'm totally new here with datatables. I installed the tutorials and my first question is:

"How do i limit the charlength for a datafield (varchar(x)). Is it possible to do it with the editor?
If i enter a longer charsequence, the editor show's me the complete inserted sequence. But inside
the DB the sequence has been cropped.

How do i limit it? I thought the editor would do it automatically.

Thank you.

Replies

  • allanallan Posts: 61,665Questions: 1Answers: 10,095 Site admin
    You would apply a validation method that will ensure that the character length is less than a certain amount. For example:

    [code]
    new DTField( array(
    "name" => "name",
    "dbField" => "name",
    "validator" => 'DTValidate::maxLen',
    "opts" => array(
    "maxLen" => 100
    )
    ) )
    [/code]

    Editor will then automatically reject anything which is > 100 characters with an error message.

    Regards,
    Allan
  • GeXXGeXX Posts: 3Questions: 0Answers: 0
    Ok, thank you!
This discussion has been closed.