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?
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:
js:
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.