Validating textfield name for spaces using javascript.
Validating textbox using trim(), in javascript.
Copy this code and paste it in your HTML
// trim function
{
return str.replace(/^\s*|\s*$/g,"");
}
// end trim
if (trim(document
.frmPremises
.txtpremisescontactname
.value
) == '') {
alert("Enter Contact Name.");
document.frmPremises.txtpremisescontactname.focus();
return(false)
}
Report this snippet
Comments
Subscribe to comments