While saving the catalog item client script, it give me an error

Line no :-23  arr.push(data[i].name1.toString().replace(/\s/g, "") ;

Could not save record because of a compile error: JavaScript parse error at line (23) column (57) problem = missing ) after argument list (<refname>; line 23)
 
 
and we have a table named site using, in that site using table Name value stored, if the name value is already present in the table then it give me an error.
 
In your code, where you compare the entered value wiith the already present value in the site using table?

like i said i gave a sample code, obviously typos were expected.

share your full code for me to look upon

 also that i made some edit to the original ,please note

Full code:-


function onSubmit() {
var arr=[];
var loc=g_form.getValue('create_new_sites');// Internal name of multiline variable set
if(loc == '[]' ){
g_form.addErrorMessage('You must enter at least 1 row');
return false;
}
var data = JSON.parse(loc);
var ct= 0;
for(var i in data){
if (data.hasOwnProperty(i)) {
arr.push(data[i].name1.toString().replace(/\s/g, "") ;
}

ct=ct+1;
}


function removeDuplicate(arr) {
var c;
var len = arr.length;
var result = [];
var obj = {};
for (c = 0; c<len; c++) {
obj[arr[c]] = 0;
}
for (c in obj) {
result.push(c);
}
return result;
}
if(removeDuplicate(myArr).length>0){
g_form.addErrorMessage('Duplicate value present');
return false;
}
}

function onSubmit() {
var arr=[];
var loc=g_form.getValue('create_new_sites');// Internal name of multiline variable set
if(loc == '[]' ){
g_form.addErrorMessage('You must enter at least 1 row');
return false;
}
var data = JSON.parse(loc);
var ct= 0;
for(var i in data){
if (data.hasOwnProperty(i)) {
arr.push(data[i].name1.toString().replace(/\s/g, "")) ; //added a ) here
}

ct=ct+1;
}


function removeDuplicate(arr) { 
var c; 
var len = arr.length; 
var result = []; 
var obj = {}; 
for (c = 0; c<len; c++) { 
obj[arr[c]] = 0; 
} 
for (c in obj) { 
result.push(c); 
} 
return result; 
} 
if(removeDuplicate(myArr).length>0){
g_form.addErrorMessage('Duplicate value present');
return false;
}
}

mark correct if this works for you