coupe-r Posted August 17, 2011 Share Posted August 17, 2011 Hi All, I have a form with a submit button. When you click the button, it calls (posts) another page to check the validation and returns with a success message or an error message. If there is an error message, I need that <input> element to change class. I can do it with PHP, but when jquery is involved, I'm not sure where to start. JQuery: function updateButton() { $('#errors').hide(); $.post('app_edit_validation.php', { ref_name1: document.form1.ref_name1_txt.value, }, function(output) { $('#errors').html(output).fadeIn(2000); }); } Input from main form: <input name="ref_name1_txt" type="text" <?php if(isset($ref_name1_error)) { echo 'class="textboxError"'; } else { echo 'class="glow"'; } ?> id="ref_name1_txt" value="<?php if(isset($ref_name1)) {echo stripslashes($ref_name1);} ?>" size="35" maxlength="35" /> secondary php page for processing: $ref_name1 = trim(mysqli_real_escape_string($connect, $_POST['ref_name1'])); if(empty($ref_name1)) { $ref_name1_error = 1; $val_error[] = 'Reference 1 Name is empty.'; } As you can see, if $ref_name1_error isset, class="textboxError. Unfortunately, I need the secondary php page to post back the $ref_name1_error variable and then the main form page updates that input. Any ideas? Sorry if this wasn't clear enough. Let me know if you have any questions. Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2011 Share Posted August 17, 2011 You don;t seem to have posted any relevant code. Where is your jQuery? Quote Link to comment Share on other sites More sharing options...
coupe-r Posted August 17, 2011 Author Share Posted August 17, 2011 Its the very first CODE section. I initially forgot it, but modified the posting. You may have looked at this as I was modifiying it. Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2011 Share Posted August 17, 2011 I still don;t see any relevant code. Take a look at http://api.jquery.com/css/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.