jQuery addClass example
Change class name on click in jQuery
by ashhaq12345
HTML
<form id="info4all">
First name & Last Name:<br>
<input type="text" name="Name"><br>
Phone Number:<br>
<input type="tel" name="PhoneNumber">
<br> Email address:<br>
<input type="Email" name="Email">
<br> Date:<br>
<br><input type="Date" name="Date">
<input type="radio" name="Selection" value="Dates" checked> Morning<br>
<input type="radio" name="Selection" value="Dates"> Afternoon<br>
<input type="radio" name="Selection" value="Dates"> Weekend<br>
<br>What can we help you with?
<br />
<input type="checkbox" name="Information" value="Information" />Information
<br />
<input type="checkbox" name="Questions" value="Questions" checked="checked" />Questions
<br />
<input type="checkbox" name="Staff Options" value="Staff Options" />Staff Options
<br />
<input type="checkbox" name="Other" value="Other" />Other..
<br>
<br>Choose how you wish us to contact you<br><select>
<option value="Telephome">Landline</option>
<option value="Email">Email</option>
<option value="Call">Cell</option>
<option value="In Person">In Person</option>
</select>
</br>
<br><button type="submit" value="Submit">Submit</button>
<button type="reset" value="Reset">Reset</button></br>
</form>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#banner-message {
background: #fff;
border-radius: 4px;
padding: 20px;
font-size: 25px;
text-align: center;
transition: all 0.2s;
margin: 0 auto;
width: 300px;
}
button {
background: #0084ff;
border: none;
border-radius: 5px;
padding: 8px 14px;
font-size: 15px;
color: #fff;
}
#banner-message.alt {
background: #0084ff;
color: #fff;
margin-top: 40px;
width: 200px;
}
#banner-message.alt button {
background: #fff;
color: #000;
}
JavaScript
$("#info4all").validate({
rules: {
Name : {
required: true,
minlength: 3
},
PhoneNumber: {
required: true,
number: true,
minlength: 9
},
Email: {
required: true,
email: true
},
messages : {
Name: {
minlength: "Name should be at least 3 characters"
},
PhoneNumber: {
required: "Please enter your age",
number: "Please enter your age as a numerical value",
minlength: "needs to be more numbers"
},
email: {
email: "The email should be in the format: [email protected]"
}
}
}
});