Showing posts with label Validations. Show all posts
Showing posts with label Validations. Show all posts

Friday, January 10, 2014

How to hide all Validators from JavaScript in .NET?

Here is how you can hide all validator messages from below JavaScript.  

function HideValidators() {
if (window.Page_Validators)
for (var vI = 0; vI < Page_Validators.length; vI++) {
var vValidator = Page_Validators[vI];
vValidator.isvalid = true;
ValidatorUpdateDisplay(vValidator);
}
}

Tuesday, January 07, 2014

How to hide Validation controls from JavaScript in .NET?

Here is how you can hide validation summary using the below JavaScript.  Call this in your aspx page. This should do trick for you.

// Hiding all validation contorls  
for (i = 0; i < Page_Validators.length; i++) {
ValidatorEnable(Page_Validators[i], false)
}


It works in IE and Mozilla. Hope this helps

Thursday, October 24, 2013

How to hide Validation Summary from JavaScript in .NET?

Here is how you can hide validation summary using the below JavaScript.  Call this in your aspx page. This should do trick for you.

function HideValidationSummary(){

if (typeof(Page_ValidationSummaries)!= "undefined"){ //hide the validation summaries
for (sums = 0; sums < Page_ValidationSummaries.length; sums++) {
summary = Page_ValidationSummaries[sums];
summary.style.display = "none";
}
}

}

It works in IE and Mozilla. Hope this helps

 

Wednesday, June 05, 2013

How to Validate Date based on format “MM/dd/YYYY” in VB.NET

Here is the sample code snippet which I wrote to do date validation for a particular format and culture.

   1: Private Function validateDateFormat(ByVal strDate As String) As Boolean
   2:     Dim isValid As Boolean = True
   3:     Dim provider As CultureInfo = CultureInfo.GetCultureInfo("en-us")
   4:     Dim formats As String = "d" '"MM/dd/yyyy"
   5:     Dim dateValue As DateTime
   6:     Try
   7:         If DateTime.TryParseExact(strDate, formats, provider, DateTimeStyles.None, dateValue) Then
   8:             isValid = True
   9:         Else
  10:             isValid = False
  11:         End If
  12:     Catch ex As Exception
  13:  
  14:     End Try
  15:     Return isValid
  16: End Function


You can change the formats and CultureInfo to your own custom information. Here is my pervious blog which describes how formatting date time can be done using string object.

Friday, June 24, 2011

How to: Dummy Credit card # for Testing

Here are list of credit card numbers which we can use for testing purpose. You can use this numbers and give other details like year and month and cvv as dummy ones. These  works for testing purpose.

Credit Card Type

Credit Card Number

American Express

378282246310005

American Express

371449635398431

AMEX Corporate

378734493671000

Diners Club

30569309025904

Diners Club

38520000023237

Discover

6011111111111117

Discover

6011000990139424

JCB

3530111333300000

JCB

3566002020360505

MasterCard

5555555555554444

MasterCard

5105105105105100

Visa

4111111111111111

Visa

4012888888881881