Showing posts with label form field validation. Show all posts
Showing posts with label form field validation. Show all posts

Tuesday 19 August 2014

Input field JQuery float validation, decimal validation

$('#price').keyup(function(e){
      var entered_value = $(this).val();
  var regexPattern = /^\d{0,8}(\.\d{1,2})?$/;         
      //Allow only Number as well 0nly 2 digit after dot(.)
      if(regexPattern.test(entered_value)) {
        alert("false") ;  
      } else {
         alert("true");
      }
});

Wednesday 25 June 2014

Alphanumeric Validation

Enter text filed only to allow alphabit & Numbers 
function alpha_numeric_validation(arg){
 var valReg = /^[A-Za-z0-9]+$/;
 if(valReg.test( arg ) ) {
  return false;
 } else {
  return true;
 }
}

Alpha Space Validation in JS

Enter text file allow allphabi & space only
function alpha_space_validation(arg){
 var valReg = /^[A-Za-z ]+$/;
 if(valReg.test( arg ) ) {
  return false;
 } else {
  return true;
 }
}

Email Validation - Form field Validate Email Address

alert(email_validation("asasas"))
function email_validation(arg){
 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
 if( !emailReg.test( arg ) ) {
  return false;
 } else {
  return true;
 }
}