Jump to content

need help with jquery form validation plug-in


et4891

Recommended Posts

I'm not sure where I can find the plug-in that I need to do this so I randomly found one form validation and used it but still not sure what I can do to make it how I want it.

 

There are a few requirements I need for my form validation

I have four fields

 

Username         which is a required field and must be 3-6 characters in length

Birthday            which must be a date

Email                 which is also required with a valid email address

Home Page       which must be a valid url

 

Also if any of those requirements aren't met then the background of the text field will be some other color except white for 3 seconds then back to original white.

 

Anyone know where I can find a plug-in for such requirement?

 

Or if someone can give me a hand with the current plug-in I have now....

 

the plug-in I have now I just have to put

 

class="required email"
 

 

then it'll validate if it's a valid email and make sure the field is required if not filled.

I did some work to make the username to meet the requirement with 3-6 characters in length and background will change and applied for 3 seconds only

 

this is my code

 

	$("form").validate();
	
	$("#form").on("submit", function (){

		user = $("#username").val().length;    
		if (user < 3 || user > 6)
		{
			$("#username").css("background","yellow");

			setTimeout(function ()
			{
				$('#username').css('background', 'white'); 
			}, 3000);
		   return false;
		}

but this only applies to username the headache I'm having now is how to apply the background change to all the other 3 fields....

 

Anyone able to give me a hand?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.