0

I'm trying to debug this function in Firefox/Firebug and it says that "dbasedata.remove" is not a function??

function dbasetype(){

var dbasedata = document.forms[0]._dbase_name.value;
        dbasedata = dbasedata.toUpperCase();
        dbasedata = dbasedata.replace(/\s/g, "");
        dbasedata = dbasedata.remove("UK_CONTACTS","");

if (dbasedata != "") {
        _area.value = _dbase_name.value;            
    } }
5
  • 3
    Firebug is correct. There is no such method. You probably want replace(). Commented May 31, 2012 at 9:30
  • I agree with Firebug, what are you trying to accomplish with 'dbasedata.remove("UK_CONTACTS","")' ? Commented May 31, 2012 at 9:31
  • dbasedata contains the value of the object _dbase_name. Do you want to remove the object or edit it's value? Commented May 31, 2012 at 9:31
  • I want to remove UK_CONTACTS from the string so I can test if there is any data left in the string. Commented May 31, 2012 at 9:35
  • Use replace(). If you replace something with an empty string it's effectively removing it. Or if all you want is to check if it has some specific value, just test for it directly: if( dbasedata == "UK_CONTACTS" ) ... Commented May 31, 2012 at 9:37

3 Answers 3

4

It's because JavaScript strings have no such method as remove().

You can see the available methods here.

If you want to replace "UK_CONTACTS" with "" then see the replace() method instead:

dbasedata = dbasedata.replace("UK_CONTACTS","");
Sign up to request clarification or add additional context in comments.

Comments

0

Use

dbasedata = dbasedata.replace(/UK_CONTACTS/, "");

instead.

Comments

0

A string object does not have a Remove() function. Firebug is correct. You might want to use replace() instead:

function dbasetype(){

var dbasedata = document.forms[0]._dbase_name.value;
        dbasedata = dbasedata.toUpperCase();
        dbasedata = dbasedata.replace(/\s/g, "");
        dbasedata = dbasedata.replace("UK_CONTACTS","");

if (dbasedata != "") {
        _area.value = _dbase_name.value;            
    } }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.