Skip to main content
ferHN
Participant
April 7, 2016
Question

Validation of customized text fields

  • April 7, 2016
  • 1 reply
  • 618 views

Hello, I am a novice in JS , I want to validate a text field , say that this question : Enter the capital of Spain : < text field > , then the answer is there Madrid, then I want an alert "right answer" if you enter Madrid and alert " Wrong answer " if you write another word appears. Greetings.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 7, 2016

Do you want this message to appear as soon as the user exits the field, or when you press a button to grade the test?

ferHN
ferHNAuthor
Participant
April 7, 2016

When the user leaves the field.

try67
Community Expert
Community Expert
April 7, 2016

The use this as the custom validation script of that field:

if (event.value) {

    if (event.value=="Madrid") app.alert("Right answer.",3);

    else app.alert("Wrong answer.");

}