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

134
Vistas
How can a form accept only a particular data type?

So I have a form that gets student ID and Name, stores it in a JSO file then displays it automatically when a button is clicked . But now I want the form to filter the response of the students such that a student can only enter integers for the id and string for the name


async function addStudent() {
    const url = server + '/students';
    const student = {id: studentId, name: studentName};
    const options = {
        method: 'POST',
        headers: {
            'Content-Type' : 'application/json'
        },
        body: JSON.stringify(student)
    }
    const response = await fetch(url, options);
}

I tried googling everywhere but I couldn't find anything

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When your button is pressed, I would have your values be checked before going through your post request. Something formatted like the following:

if (isNaN(form.studentId.value) && !(isNaN(form.name.value))) {
    addStudent();
} else {
    alert("Invalid form!");
}
about 4 years ago · Juan Pablo Isaza 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