Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!