labman
labman

Reputation: 59

javascript remove function not valid

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;            
    } }

Upvotes: 0

Views: 126

Answers (3)

papaiatis
papaiatis

Reputation: 4291

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;            
    } }

Upvotes: 0

powtac
powtac

Reputation: 41080

Use

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

instead.

Upvotes: 0

Matt
Matt

Reputation: 75327

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","");

Upvotes: 4

Related Questions