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 4320940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:41:19+00:00 2026-05-21T08:41:19+00:00

I have a live preview form: http://davidwalsh.name/jquery-comment-preview Which uses jquery to display the preview

  • 0

I have a live preview form: http://davidwalsh.name/jquery-comment-preview
Which uses jquery to display the preview in real time:

$(document).ready(function() {
  $('#live-preview-form input, #live-preview-form textarea').bind('blur keyup',function() {
    $('#lp-comment').text($('#comment').val());
    $('#lp-comment').html($('#lp-comment').html().replace(/\n/g,'<br />'));
  });
});

what if i need to apply some PHP function on “#comment” which comes from textarea, before putting it in the jquery validate?

  • 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-21T08:41:19+00:00Added an answer on May 21, 2026 at 8:41 am

    If you want to apply PHP functions, you must use jquery ajax(POST the value to a php page and get the returned result).

    For example:

    process.php:

    <?php
    function my_function($in){
        ....
        return $out;
    }
    
    $result = my_function($_POST['q']);
    echo json_encode($result);
    ?>
    

    js:

    $(document).ready(function() {
      $('#live-preview-form input, #live-preview-form textarea').bind('blur keyup',function() {
    
        $.ajax({type: "POST", url: "function.php", data:{ "q": $('#comment').val()}, dataType: "json", 
          success: function(result){
            $('#lp-comment').text(result);
            $('#lp-comment').html($('#lp-comment').html().replace(/\n/g,'<br />'));
          }});
      });
    });
    

    However, this is not recommended because users query your server every time when they type a single character.
    The best way is to by a javascript function instead of a PHP function.

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

Sidebar

Related Questions

I have 10 fields which will preview in live before submit Example $(function ()
I'm using a very simple jQuery live preview method which works brilliantly. But how
I'm trying to make a code live preview form with jQuery, so when people
I have a live rails website and I want to have a form with
O, so i have a 'live search' ajax search, which currently runs an sql
I have a website with live stats that I wish to display to every
I have a really simple Javascript BBCode Parser for client-side live preview (don't want
i have this problem, im using live preview, while the user is typing they
I have a form with several fields that has a jquery autosave function that
I need to build a live preview in Flash which will show a user

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.