Click here to Skip to main content
15,068,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here i am checking only for sapaces

JavaScript
if (/^\s*$/.test(txtSSAETitle.value) || /[\s]/.test(txtSSAETitle.value)){
    txtSSAETitle.focus();
    alert("AE title should not be blank.");
    return false;              
}

but [spacesjohnspacesHenry] or [johnspacesHenry] this should be allowed.(No alert generate for this)
Posted
Updated 15-Apr-12 19:59pm
v2

hey,

for trim text in javascript try following

C#
if (txtSSAETitle.value.replace(/^\s+|\s+$/g, "") == "" || txtSSAETitle.value.replace(/^\s+|\s+$/g, "") == "") {
                txtSSAETitle.focus();
                alert("AE title should not be blank.");
                return false;
            }


Hope it will Help u
Best Luck
happy Coding
:)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900