File upload, Number & E-Mail validation in jQuery


var fsize = $(‘.fileTo_Upload’)[0].files[0].size;
if(fsize>2500000){
alert(“Please upload image below 2MB”);
}
if(!/(\.png|\.jpg|\.gig|\.jpeg)$/i.test($(‘.fileTo_Upload’).val()))
{

alert(“Please upload correct file format Photo”);
/* $(“.phh”).html(“Invalid text file type.\n”);*/
err++;
}

  var email = jQuery( “#dummy_email_id” ).val();
          var regexpEmail = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
         if (regexpEmail.test(email)) {
 alert(“true”)
         }
<script>
jQuery(document).ready(function(){
jQuery(“#phone_num”).blur(function(){
var value = jQuery(“#phone_num”).val();
var test = /^[0-9]+$/.test(value);
if(test==false){
jQuery(“.num_err”).show();
}else{
jQuery(“.num_err”).hide();
}
});
});
</script>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s