I have the following code:
var isvalid = [];
function namevalidation(){
var checkname = $("#first-name").val();
var namevalid = new RegExp("(^[a-zA-Z'-]+$)");
var name_error = $("error");
if(checkname.match(namevalid)){
$(name_error).css("display","block");
if($.inArray('name', isvalid) == -1){
isvalid.push('name');
}
}else{
$(name_error).css("display","none");
if($.inArray('name', isvalid) > -1){
isvalid.splice("name",1);
}
}
}
I do not know the position of the string inside the array, as i would have many similar functions for other inputs. Based on the code above how do i remove the string 'name' from the array 'isvalid'?