I want to do validation Without any plugin as follows in jquery:
1.User Id Cannot Contains Space,
2.Password Must Be greater than Six characters,
3.all Fields are Required.
I can't do this Please Help Me.
Jquery:
$('#form').submit(function (event) {
//getting elements
var id=$('#userId').val();
var pw=$('#pw').val();
//validating
//$('span').text('These Fields Are Required...').show().fadeOut(100);
if ( id !== "" && pw !=="") {
var json={'User Id':id,'Password':pw};
$.each(json,function(p,v){
alert(p+": "+v);
});
return;
}
else if( id.indexOf(' ')>=0 ){
$( "span" ).text( "User Id Cannot Contain Space!" ).show().fadeOut( 1000 );
}
if(id==="" || pw==="")
{
$( "span" ).text( "Some Feilds are Required!" ).show().fadeOut( 1000 );
}
event.preventDefault();
});