Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Fill Gaps

by zhshqzyc
on Nov 23, 2006 at 18:27 UTC ( #585760=offtopicroot: print w/replies, xml ) Need Help??

This posting has been designated as off-topic for the PerlMonks web site. Please do not respond to it.


Hi ,how to fill these fragements. I spent two days, no results.
<html> <head> <title>Gaps</title> <script langauge="javascript"> function start() { __A________________________________________________; } function validate( event ) { if ( B_____{ event.preventDefault(); C__________________; alert( "Wrong format for age!" ); } } </script> </head> <body onload="start()"> <form method="post" action="/cgi-bin/prob3.cgi"> <p> Your age: <input name="age" type="text"> <p> <input type="reset"> <input type="submit" value="Submit"> </form> </body> </html>
A---Make the function validate a listener for the submit event(for the + form element). B--- An expression that is true if the value of the textbox does not c +ontain one to three digits. C--Select the text box.

Considered by jdporter: reap OT homework.
Unconsidered by Arunbear: keep (and edit) votes prevented reaping; (Keep: 5, Edit: 3, Reap: 17)

Replies are listed 'Best First'.
Re: Fill Gaps
by Joost (Canon) on Nov 23, 2006 at 20:17 UTC
Re: Fill Gaps
by GrandFather (Sage) on Nov 23, 2006 at 20:35 UTC

    It's not clear what you want to achieve. Maybe the following Perl code will help? Just replace the text in the hash with whatever you want to fill the gaps with.

    use strict; use warnings; my %fillers = ( A => "Whatever is required for the A gap here", B => "Whatever is required for the B gap here", C => "Whatever is required for the C gap here", ); while (<DATA>) { s/_*(\w)_+/$fillers{$1}/eg; print; } __DATA__ function start() { __A________________________________________________; } function validate( event ) { if ( B_____{ event.preventDefault(); C__________________; alert( "Wrong format for age!" ); } }

    Prints:

    function start() { Whatever is required for the A gap here; } function validate( event ) { if ( Whatever is required for the B gap here{ event.preventDefault(); Whatever is required for the C gap here; alert( "Wrong format for age!" ); } }

    DWIM is Perl's answer to Gödel
      given Joost's observations (++) and the reply from GrandFather (++), I nearly have to upvote and keep the OP (--) ...
          ... just so it remains as an object lesson!

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2019-12-14 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?