It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

ignore space in javascript

ignore space in javascript

Postby sundarraj_mca on Fri Jun 20, 2008 8:10 am

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.
sundarraj_mca
 
Posts: 22
Joined: Wed May 14, 2008 5:06 am

Postby rangana on Fri Jun 20, 2008 9:29 am

You could either use indexOf() method.
Code: Select all
if(!(txt.indexOf('')==-1))
   {
   alert('There\'s a space');
   }

...or match() method.
Code: Select all
str.match(/^[\d]{6}$/)


Hope it helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 4 guests