Saturday, 24 August 2013

Why is my jQuery function not being called correctly?

Why is my jQuery function not being called correctly?

I have this jQuery function that is using another jQuery library called
html5csv.js (which explains some of the CSV stuff you will see)
Here is it:
function validateNewQuiz()
{
CSV.begin("#upload_csv").go(function(e,D)
{
if (e)
{
return console.log(e);
alert("Sorry, an error occured");
}
var s = "";
for (var i = 0; i <= D.rows.length - 1; i++)
{
s +=D.rows[i].join(',');
s += "\n";
}
var fullString = s;
if(/^(([^,]+,){4}[^,]+\n){3}$/.test(fullString))
{
return true;
}
else
{
return false;
}
});
}
Here is how I am trying to call my function, from an onsubmit within my form:
<form method="post" action="createplay.php" onsubmit="return
validateNewQuiz();" enctype="multipart/form-data">
My function has been thoroughly tested, along with my regex to make sure
it was working. When I decided to implement it into my large document, and
wrap it around function validateNewQuiz(){ //my function here } , it
stopped working.
I did not make my tests with the onsubmit part within my form either.
Does anyone have any suggestions to why my form is always submitting, even
when my function should be returning false?

No comments:

Post a Comment