Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
Validating C#'s Long Variable value in Javascript

I have a form wherein a user can enter a value associated with a nullable long property of my ViewModel. But because I have an 'onblur' event on that text box, I am trying to validate the entered value in my textbox.onblur() event and ensure that it does not exceed the C#'s, long.MaxValue. Here is my "blur" code on that text box.

var value = $(this).val();
console.log(value > 9223372036854775807);

if (value<= 1 || value > 9223372036854775807) {             
            $('#divValueError').text("Invalid Value!");
            return false;
        }

But Javascript is returning false on that console.log statement if I enter 9223372036854775808. How do I check if the number entered by the user falls within the limits of a C# long value?

I understand 64 bit numbers are not supported by Javascript. I also could not get my [Range] data annotation on that property to fire before this blur event is called, even though I tried

if (!$(this).valid()) {

            return false;
        }

Please let me know how I can throw a client side error if the value entered by the user falls outside the boundaries of a C#'s long data type value.

Thanks!

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Perfect Answer : I am Providing example that will solve your problem. In this , you first have to convert your value in string and then in biginteger. Reference link added for better guidance.

var valuecompare = BigInt("9223372036854775808");
var valuebase = BigInt("9223372036854775807");

console.log(valuecompare);
console.log(valuebase);

if (valuecompare > valuebase) {             
            console.log('greater value');
        }
else{
    console.log('less value');
}

Reference Link : https://www.smashingmagazine.com/2019/07/essential-guide-javascript-newest-data-type-bigint/

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda