Sunday, April 8, 2012

jQuery Validation custom validation adding no space validation

I have a form where the user can update his name and last name. I use jQuery validation to validate the form. How can I validate if the user put spaces?

here's what i have:



$('#submit').click(function() {

var valid = $("#myform").valid();

if(!valid) {

return false;



type: "POST",

url: 'save',

data: $('#myform').serialize(),

dataType: 'json',

cache: false,

success: function(result) {

// redirect to another page








<form id="myform" method="post" action="">


<legend>update name</legend>


<label for="fname">Name</label>

<em>*</em><input id="fname" name="fname" size="25" class="required" minlength="2" />



<label for="lname">Last Name</label>

<em>*</em><input id="lname" name="lname" size="25" class="required" minlength="2" />



<input id="submit" type="submit" value="Submit"/>





Source: Tips4all

No comments:

Post a Comment