Is it possible to check the content of textarea must contain previous inputs' all words using javascript or jquery? and if not contains all words than the value of textarea is invalid or will not submit. Please reply me soon.
Thanks.
Is it possible to check the content of textarea must contain previous inputs' all words using javascript or jquery? and if not contains all words than the value of textarea is invalid or will not submit. Please reply me soon.
Thanks.
In JavaScript you can access the value of the textareas inner text by accessing the value.
Ex: document.getElementById("myTextarea").value = "Fifth Avenue, New York City";
You can then check this as you would any other JavaScript and on submit run the tests
This will check the value of the text entered on each keyup event against the value you define. If that returns true the submit property will not be disabled, otherwise it will be.
$('input[type="submit"]').prop('disabled', true);
$("textarea").on("keyup", function(){
if($(this).val() == 'value to check against'){
$('input[type="submit"]').prop('disabled' , false);
}
else{
$('input[type="submit"]').prop('disabled' , true);
}
})
https://jsfiddle.net/bgdogf2c/
If checking for an item in an array:
$('input[type="submit"]').prop('disabled', true);
$("textarea").on("keyup", function(){
if($.inArray($(this).val(), [ "one", "two", "three"] ) != -1){
$('input[type="submit"]').prop('disabled' , false);
}else{
$('input[type="submit"]').prop('disabled' , true);
}
})
I think I understand what it is you're trying to get done: You want the user to utilize the previously given input of 35 words which is retrieved from input fields, but also give the user the option to add more. This addition is optional.
Check it out here
To be clear
input: 1, 2, 3 | textarea: 1, 2, 3 | returns true
input: 1, 2, 3 | textarea: 1, 2, 3, 4 | returns true
input: 1, 2, 3 | textarea: 1, 3, 2 | returns true
input: 1, 2, 3 | textarea: 3, 2, 1 | returns true
input: 1, 2, 3 | textarea: 2, 2, 1 | returns false
input: 1, 2, 3 | textarea: 1, 2 | returns false
JS