protected void ValidateISBN(object source, ServerValidateEventArgs args) { if (this.txtISBN.Text != isbn_book) { this.cvISBN.ErrorMessage = ""; if (args.Value.Length == 13) { try { long.Parse(args.Value); if (!Crud.CheckRegisteredISBN(this.txtISBN.Text)) { args.IsValid = true; } else { this.cvISBN.ErrorMessage = "This ISBN is already registered."; args.IsValid = false; } } catch (Exception) { this.cvISBN.ErrorMessage = "Invalid ISBN. Only numbers."; args.IsValid = false; } } else { this.cvISBN.ErrorMessage = "ISBN must have 13 digits."; args.IsValid = false; } } }