How to read line by line of a text area HTML tag

后端 未结 5 1080
借酒劲吻你
借酒劲吻你 2020-11-29 21:10

I have a text area where each line contains Integer value like follows

      1234
      4321
     123445

I want to check if the user has re

5条回答
  •  既然无缘
    2020-11-29 22:11

    This would give you all valid numeric values in lines. You can change the loop to validate, strip out invalid characters, etc - whichever you want.

    var lines = [];
    $('#my_textarea_selector').val().split("\n").each(function ()
    {
        if (parseInt($(this) != 'NaN')
            lines[] = parseInt($(this));
    }
    

提交回复
热议问题