Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi team

I have been struggling to resolve this issue "validation is not a problem" and yet i have used the correct order of using jquery libraries and still experience the same problem.

What I have tried:

JavaScript
<pre>$().ready(function() {

$('#signup-form').validate({
	rules:{
		name: {
			required:true,
			minlength:12
			},
			
			surname:{
			required:true,
			minlength:15
			},
			
			email:{
				required:true,
				email:true
			
			},
			
			confirm_email:{
				required:true,
				confirm_email:true,
				equalTo:"#email"
			
			},
			phone_number: {
				required:true,
				minlength:10
			
			},
			service_number:{
				required:true,
				minlength:10
			
			},
			agree: {
				required:true
			},
			messages: {
				name: {
					required:"Please enter your name",
					minlength:"Your name must have at least 12 characters"
				},
				surname: {
					required:"Please enter your surname",
					minlength:"Your surname must have at least 15 characters"
					
				},
				email: {
					required:"Please enter your email address",
					equalTo:"Please enter the same email address as above"
				},
				agree: "Please accept our policy"
				
			
			
			}	
		
	
	 }


	})
	
});

jQuery.validator.addMethod("laxEmail", function(value, element) {
  // allow any non-whitespace characters as the host part
  return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:\S{1,63})$/.test( value );
}, 'Please enter a valid email address.');


<script src="js/messages.min.js"></script>
    <script src="js/signup-form.js"></script>
    <script src="js/jquery.validate.js"></script>
Posted
Updated 10-Feb-23 4:26am
Comments
Andre Oosthuizen 10-Feb-23 10:14am    
Side note, I will handle surname differently, if my surname is 'Jobs', I will fail your validations.

1 solution

Error occurs when the jQuery validation plugin is not loaded or the jQuery-related scripts are loaded in an incorrect order.
The validation plugin should be loaded after all other jQuery libraries - newest is version 1.19.5 which you can get from HERE. You will see the validate function in this file, should solve your problem.
 
Share this answer
 
Comments
Gcobani Mkontwana 17-Feb-23 18:47pm    
@Andre Oosthuizen thanks so much let me test and update you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900