开发者

Text area validation?

开发者 https://www.devze.com 2023-02-13 04:31 出处:网络
I want to validate mytext are while entering data. I had written code for on keypress event. function validateQuestionTextArea(questionid)

I want to validate my text are while entering data.

I had written code for on keypress event.

function validateQuestionTextArea(questionid)
{

  var txtbx=$('questions-'+questionid).value;

  if(txtbx.开发者_开发技巧length > 99)
  {
    showValidationMessage('questionMaxLengthValidation');
    return false
  }

  return true

}

The problem with this is that I can use backspace or delete once it reached the 100.

Which event should I use?


you might wanna use KeyUp instead ^^


see jquery way similar question.. or follow below steps

first get the data then trim from both side then count and compare with max length

0

精彩评论

暂无评论...
验证码 换一张
取 消