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 Whitespace

Ignore Whitespace

Postby yksnirk on Wed Apr 22, 2009 5:11 am

I have code on my site that validates user inputs on a form, and gives an error message of they enter any non-alphabetic character.
My problem is that if they live in a suburb with 2 words (eg "st kilda") it will detect the space as a non-alphabetic character an return an error message. How can I edit the following code to ignore the space??

if (!isAlphabetic(document.getElementById("Suburb").value))
{
alert("Please enter suburb properly");
document.gbook.Suburb.focus();
return false;
}


function isAlphabetic(val)
{
if (val.match(/^[a-zA-Z]+$/))
{
return true;
}
else
{
return false;
}
yksnirk
 
Posts: 1
Joined: Wed Apr 22, 2009 5:04 am

Who is online

Users browsing this forum: No registered users and 9 guests