| View previous topic :: View next topic |
| Author |
Message |
sundarraj_mca
Joined: 14 May 2008 Posts: 19
|
Posted: Fri Jun 20, 2008 9:10 am Post subject: ignore space in javascript |
|
|
hai
how to ignore space in text input
i have a textbox for Demand Draft no in which only 6 characters are allowed my script accepts 6 numeric correctly but it also accepts space. i need validate it. |
|
| Back to top |
|
 |
|
|
rangana 500+ Club

Joined: 27 Feb 2008 Posts: 629 Location: Cebu City Philippines
|
Posted: Fri Jun 20, 2008 10:29 am Post subject: Re: ignore space in javascript |
|
|
You could either use indexOf() method.
| Code: |
if(!(txt.indexOf('')==-1))
{
alert('There\'s a space');
}
|
...or match() method.
| Code: |
str.match(/^[\d]{6}$/)
|
Hope it helps. |
|
| Back to top |
|
 |
|