Which code segment should you use?

You are developing a customer web form that includes the following HTML.
<input id=”txtValue” type=”text” />
A customer must enter a valid age in the text box prior to submitting the form.
You need to add validation to the control.
Which code segment should you use?

You are developing a customer web form that includes the following HTML.
<input id=”txtValue” type=”text” />
A customer must enter a valid age in the text box prior to submitting the form.
You need to add validation to the control.
Which code segment should you use?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Mahaha Meeee

Mahaha Meeee

I’m really not sure about D, that regex flags input like 90,90,80000.2343.234 as correct… Is 90,90,80000.2343.234 a “valid” age?

Valikhan

Valikhan

Seems like the question’s text not related with image

Alex

Alex

It’s surely B

Terminator

Terminator

Funny as hell. 12939123.19239,1293 return: non existing object. GODDAMN

Firefox360

Firefox360

@Alex, no it is not B. B checks only whether or not the input is empty. D checks if a number is entered. Okay the regular expression of D is not completely correct, but it is the answer that approaches the correct answer the most.

ptb

ptb

Perhaps the user expresses their age as a string e.g. “seventy”.
It should be clear that the data input should be numeric