2

I have the following code which is styled after the example at the following link:http://phpgrid.com/example/custom-data-validation/

I am using their phpgrid component and need to have custom rules which are constructed in this manner:

$dg -> set_col_customrule(colname,function);

And this is what I have:

$dg -> set_col_customrule("Email","chkemail");

Making a long story short, my javascript would not work although phpgrid support assured me that my javascript worked fine for them, it still would not catch the email errors. So, after some research, I discovered that I need to code it differently because of the ondomready event.

But my function keeps giving me the error of:

Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) or '$' in C:\wamp\www\Enterprise\alldisplay.php on line 193

I wasn't real sure where to locate the code in my PHP page, so I have in before my other PHP functions. It's purpose is to capture errors via the custom rule setting.

$(document).ready(function chkemail(value,colname){

    alert('am at checking email');
    alert('Data..' + colname);
    alert('Length..' + length);
    if ((jQuery('#Email').length()) === 0) {
        return [false, "You must enter at least one Email Address."];
    } else {
        return [true, ""];
    }
});

Any help appreciated ...

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • What's on line 193 of `alldisplay.php`? – Barmar Feb 06 '16 at 00:03
  • Or on the line before line 193. If you dump the code onto an Excel sheet it is an easy way to count rows if you don't have any editor program. – Steve Feb 06 '16 at 07:35
  • If client JavaScript code `$(document).ready(function chkemail(value,colname){` is inside your PHP tags the parser would throw an `unexpected '('` error at `$(document...` because it wouldn't be expecting a bracket after a $. – Steve Feb 06 '16 at 07:40
  • I understand what your saying - the coding is fashioned after an example that I found on this website that was a response to "why the javascript would not execute". Here is the link:http://stackoverflow.com/questions/25050012/javascript-not-working-in-script-tags - I am just trying to resolve why my javascript will not execute even when I follow phpgrid example. I don't know whither its where I have located the script or their example is wrong. It just won't catch the email errors.. – Martha J Sayers Feb 07 '16 at 17:22

0 Answers0