Results 1 to 3 of 3

Thread: Field validation w/js and jquery

  1. #1
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Field validation w/js and jquery

    Hello!

    I am currently a student at a local university studying C# and .NET. I do have a personal project however that is making my life crazy!

    In adding a simple validated email form to a personal website I am adding text for the user to enter for validation of the form however it is not working correctly. For some reason, on clicking the submit button a validation error prints to screen even when the correct code is entered.

    I appreciate any help you can offer. I hope the information I've supplied is sufficient.

    I am using the scripts and libraries listed in the code below:

    Code:
    Script includes: 
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>	
    <script type="text/javascript" src="/jquery.validate.js"></script>	
    <script type="text/javascript" src="/inProgress/javascript/formValidation.js"></script>
    
    
    <p class="labelCode">Please enter code:</p> 
    <p id="codeVerify" name="codeVerify" value="xM14z">xM14z</p>
    <input type="code" name="code" id="code" size="15" class="required">
    
    code for formvalidation.js file:
    
    	$(document).ready(function() {
    	   $('#entry').validate({
    	   	  rules: {
    			  
    			  name: {
    				  required: true, 
    				  rangelength: [3,35]
    				  },
    			  email: {
    				  required: true, 
    				  email: true},
    			  code: {
    				  equalTo: '#codeVerify'
    				    }
    			  },
    			  
    			  messages: {
    			  
    			  name: {required: "Please enter your name."},
    			  email: {required: "E-mail addy please.", email: "Your email must be valid!"},
    			  code: {equalTo: "Please enter the correct code!"}
    			  }
    			  
    			  
    		  
    	   });  // end of validate()
    	});
    Last edited by jscheuer1; 03-09-2012 at 04:54 AM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,925
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    You can't use a p like that. You can do it like so using a hidden input:

    Code:
    <p class="labelCode">Please enter code:</p> 
    <p><input type="hidden" id="codeVerify" name="codeVerify" value="xM14z">xM14z</p>
    <input type="code" name="code" id="code" size="15" class="required">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    sme (03-12-2012)

  4. #3
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you ~ works perfectly!

Bookmarks

Posting Permissions

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