Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a number only input field and strip out other characters? 1

Status
Not open for further replies.

bazil2

Technical User
Feb 15, 2010
148
DE
(Elementary user)

The following is an abridged input filter that removes any character that is not a-z which I believe is defined by the value 'lowercaseLetters'

To adapt this filter to make it numbers only, can anyone tell me what the value should be?

Best regards

------------------------------------
function only_a_to_z(theField, val, v, args)
{
// normal textfield. Do the filter.
s = stripCharsNotInBag(val, lowercaseLetters);

// if we have supplied a pointer to another field, we put the data there...
if (args && args.length==1) {
theField.form[args[0]].value = s;
} else {
theField.value = s;
}

return true;
 
How would we know? stripCharsNotInBag is not a JS function. It appears to be a custom function. So only you know what it does.

Judging by its name though, I would change lowercaseLetters, to a string containing only numbers.

"1234567890"

Beyond that there's now way to know what its expecting.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
You were absolutely right!

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top