Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Web Application Development with Form Validation

by Withigo (Friar)
on Feb 05, 2008 at 02:14 UTC ( #666176=note: print w/replies, xml ) Need Help??

in reply to Web Application Development with Form Validation

If it's really important to keep the existing data which the user has entered so far, I'd say validation via ajax is going to be much easier than the "crazy loops" you mentioned. So this is really more of a javascript question than a perl question.

Using prototype.js (or if you know jquery) you basically make a regular form which has its onsubmit() handler set to make the ajax call and return false. So the browser won't attempt to change to another page. (Incidentally and off-topic, but for a good example, code like this is what the Rails function "form_remote_tag" auto-generates).

The perl side will be very minimal--just collect the params, validate them however you want and return some JSON with the rejected params, or with a flag indicating success. There are many examples of code like this to be found on the prototype mailing list (archived on google groups).
  • Comment on Re: Web Application Development with Form Validation

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://666176]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2018-02-23 12:40 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.