Hello so i’m trying to trim the white spaces when the user enter spaces he get an error explaning that he should enter valid chars but if he used: ' test ' the same value is entered in the database do i need to trim that again in javascript ?
function validateForm()
{
if(trim(document.insert.aname.value) ==="")
{
alert("Animal should have a name");
document.insert.aname.focus();
return false;
}
}
function trim(value) {
return value.replace(/^\s+|\s+$/g,"");
}
please can you help ?
the input page is .JSP
You’re not actually trimming the input. You want this: