문제

I have created web application and textbox as a textarea. I am using javascript for validation. When I enter value in text box so it should be number not alphabet I have use textmode is multiple line.

My problem is that how I get multiple value from textbox and store in array in javascript and check each value is number or not. I am using the web form. Please help me.

올바른 솔루션이 없습니다

다른 팁

You can get the value from a textarea like

var txtvalue = document.getElementById("txtareaid").value

and if are using a separator then something like

var txtvaluearray = document.getElementById("txtareaid").value.split(';')

will get you all the values in an array if the seperator is ;

Edit

As per your update you can use \n as the separator and as pointed by @Sohnee you can do the validation.

As addition to rahul:

If you want the values in the textarea seperated by line, you can use \r\n as the splitter.

This is a starter for ten.

var textValues = document.getElementById("mytextarea").value.split("\n");
for (var i = 0; i < textValues.length; i++) {
    if (isNaN(textValues[i])) {
        alert(textValues[i] + " is not a number.";
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top