noamway
12-25-2006, 07:21 PM
I have a textarea in HTML:
<textarea type="text" name="tranT" onKeyUp="noBR(this.form.tranT);"></textarea>
and I try to don't let the user click on the ENTER key, but my code don't work, someone can find the problem.
I wrote this code:
function noBR(x)
{
var reg = new RegExp("[\n]", "g")
if (x)
{
if (reg.test(x.value))
{
alert("Please don't use the 'ENTER' key, Use <br> instead!");
x.value = x.value.replace(/[\n]/g,"")
x.focus();
return false;
}
}
}
<textarea type="text" name="tranT" onKeyUp="noBR(this.form.tranT);"></textarea>
and I try to don't let the user click on the ENTER key, but my code don't work, someone can find the problem.
I wrote this code:
function noBR(x)
{
var reg = new RegExp("[\n]", "g")
if (x)
{
if (reg.test(x.value))
{
alert("Please don't use the 'ENTER' key, Use <br> instead!");
x.value = x.value.replace(/[\n]/g,"")
x.focus();
return false;
}
}
}
