Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6620397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:05:39+00:00 2026-05-25T21:05:39+00:00

I have a form, which I use Text::MicroTemplate to add some fields to it,

  • 0

I have a form, which I use Text::MicroTemplate to add some fields to it, such as:
User Name
Last Name
Email

the fields are added using a loop inside a <form> tag, the data for these is validated using a regex (sent as a parameter to the template and “hidden” in the HTML in <span> tag with style display:none), so far, all is fine.

suddenly I have to add another field, for which the data has to be validated on the server side, what is the best approach for doing so? (I can of course, check the POST data, and if its incorrect, can send back the form with the relevant error message, but then, I will have to render the whole page again, which I dont do for the other fields…)

probably something with ajax?

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:05:40+00:00Added an answer on May 25, 2026 at 9:05 pm

    AJAX can avoid the whole page rendering which is a good thing™.

    You know for sure that writing AJAX code working with different browser implementations, will lead to spaghetti-JavaScript-code, so my advice is to level differences with a good JavaScript library. I have chosen jQuery, because is easy to learn and fun to use if you alredy know CSS2 selectors. There there are other good libraries YUI, Prototype, MooTools, just choose one.

    With jQuery, you can invoke an AJAX call in various ways including this simple version:

    $.post( url, parameters, callback, returned_type );
    

    where

    • url: URL of server side resource that validates input
    • parameters: an object whose properties are serialized into encoded parameters
    • callback: callback invoked when request completes ( response body and status are passed to the callback as first and second parameter ).
    • type: a string like 'html', 'text', 'xml', 'json', that tells what kind of response to expect from server.

    Usually, to send a form, you have to hook an event handler to the submit button: the event handler hijacks the submit event, giving the opportunity to validate values client-side and send them with an AJAX call.

    $( '#my_form' ).submit( function( event ) {
        // Prevent classic submission that ends with whole page render
        event.preventDefault();
        // Here iterate through form elements and do a client-side check
        ... 
        $ajax.post( ... ); 
    }
    

    I can understand that my example is oversimplifed, but that pattern is rather common: hijack-submit-event-and-do-it-another-way.
    You’ll find more examples ( including those with powerful jQuery plugins ) in chapter 11 of jQuery Cookbook, entitled Html form enhancements with plugins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a form which a user can use to create a new
I have a form in which I use autocomplete, and a link. When some
i have form that has multiple input text boxes, Which has got some text
i have database table with few text fields which i use to filter data
Lets say i have a form which have the following : Name:TextBox Email:TextBox Age:TextBox
I have a form which takes both the user details and an image uploaded
I have a form which users can add controls to and when they right
I will have a web-application which will use a few complex forms. One form
I have a form which I submit and I use .serialize to help me
I have form with few text boxes which goes through validation (both server and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.