Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Validation

  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validation

    I've got something like that:
    Code:
            <script>
                $(document).ready(function() {
                    $("#addNews").validate({
                      errorPlacement: function(error, element) {
                         error.insertAfter(element.next().next().next());
                       }
                   });
                });
            </script>
    And it works great, but now I want to send values from fields to database if everything is valid. So I modified that code so it looks like that now:

    Code:
            <script>
                $(document).ready(function() {
                    $("#addNews").validate({
                      errorPlacement: function(error, element) {
                         error.insertAfter(element.next().next().next());
                       },
                       	submitHandler: function() {
                        var ftitle     = $('#medium-input').attr('value');  
                        var fsummary   = $('#textarea summary').attr('value');
                        var fboxytext  = $('#textarea bodytext').attr('value');
                        var fpic       = $('#pic').attr('value');
                			$.ajax({  
                				type: "POST",  
                				url: "write_news_ajax.php",  
                				data: "ftitle="+ ftitle +"& fsummary="+ fsummary"& fboxytext="+ fboxytext"& fpic="+ fpic,  
                				success: function(){  
                					$('form#addNews').hide(function(){$('div.notification success png_bg').fadeIn();});
                				}
                			});
                       }
                   });
                });
            </script>
    That's not working. Page is just reloading after sending form. Form looks like that:

    Code:
    <form id="addNews" method="post" name="submit" action="">
    	
    	<fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
    		<p>
    			<label>Temat</label>
    			<input class="text-input medium-input datepicker required" type="text" id="medium-input" name="title" maxlength="40" /><br /><small>Max. 40 znaków</small><br />
                
    		</p>
    		
    		<p>
    			<label>Wstęp newsa</label>
                <textarea class="text-input textarea required" id="textarea summary" name="summary" cols="79" rows="3" maxlength="172" ></textarea><br /><small>Max. 172 znaki</small> <br />
    		</p>
    		
    		<p>
    			<label>Treść newsa</label>
    			<textarea class="text-input textarea wysiwyg" id="textarea bodytext" name="bodytext" cols="79" rows="15" maxlength="2000" ></textarea><br /><small>Max. 2000 znaków</small>
    		</p>
            
            <p>
            
            <div id="picupload_div">    
                    <p><label for="file">Obrazek:</label> <input type="file" name="picupload" id="picupload" /></p>
            </div>
            <div id="uploadedpics">
            <!-- hidden form field posts to here -->
            </div>
            <p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Zatrzymaj wgrywanie</a></p>
            
            </p>
    		
    		<p>
             <BUTTON type="submit" class="button">Dodaj newsa</BUTTON>
    		</p>
    		
    	</fieldset>
    	
    	<div class="clear"></div><!-- End .clear -->
    	
    </form>
    Any ideas how to fix it?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You can't name ids using spaces.

  • #3
    New to the CF scene
    Join Date
    May 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    You can't name ids using spaces.
    I just fixed it, but it still just reload the page.

  • #4
    New to the CF scene
    Join Date
    May 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok It works. Thanks anyway.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •