JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="txtarea" placeholder="How to stop http being entered into textarea?"></textarea>
CSS
htt p://jsfiddl e.net/95b2msaj/17/
JavaScript
$(function(){
$("#txtarea").keyup(function(){
var urlmatch = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/, newA = [], a = this.value.split(' ');
$.each(a, function (i, j) {//j = $.trim(j);
if((j.match(urlmatch) && j.charAt(0) == '(' && j.charAt(j.length-1) == ')') != false) {
newA.push(j)
}
console.log(j, '->', j.match(urlmatch) && j.charAt(0) == '(' && j.charAt(j.length-1) == ')' ) })
var o = newA.join(" ")
this.value = o;
})
});