Handled max length check when text is selected