Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am a beginner in Perl & JScript. I have to validate a form. I am using the following code. I have javascript in different file and in different directory.
print start_html( -title=>'People Data', -script=>[ { -language => 'JavaScript', -src => '/javascript/ValidateForm.js' } ] ); print table({-border=>0,-cellpadding=>4,-cellspacing=>5}, Tr({-align=>LEFT,-valign=>TOP}, [ td('Sun Id: ',textfield(-name=>'Sunid',-value=>"$sun +id",-size=>20),submit(-name=>'Load',-value=>'Get Details',-onClick=>V +alidateForm())), td({-bgcolor=>chocolate},font({-color=>white},'Enter Sun + ID and click Get Details')) ] )); print end_form; print end_html;
Javascript file contains the following code
function ValidateForm(){ var Phone=document.inFOrm.Mobile alert("In JS") return true }
I am getting compilation error. Please help me out. thanks in advance.

Replies are listed 'Best First'.
Re: working with JScript in Perl
by gellyfish (Monsignor) on Oct 08, 2006 at 08:28 UTC

    You omitted the quotes around the ValidateForm() in your Perl code, consequently it is being interpreted as a call to an (undefined) Perl subroutine.

    /J\

      Thanks. Now I am able to compile. But when i click the button alert msg is not coming. Am I missing anything?.

        Not sure, but I think you need a semicolon at the end of every javascript statement.

        --
        David Serrano

Re: working with JScript in Perl
by McDarren (Abbot) on Oct 08, 2006 at 08:27 UTC

    This compilation error you are getting - are we allowed to see it, or is it a secret?

    Is it Perl complaining, or the Javascript?

    If the former, you could try showing us the error and we might be able to help.

    If the latter, then you are asking in the wrong place.

    Cheers,
    Darren :)

      Sorry . I was getting undefined function error. I corrected the mistake highlighted by gellyfish and now its compiling but its not working. ie. Alert msg is coming when clicking the button.