You are implementing an ASP.NET page that includes a text box. You need to validate values that are
typed by users to ensure that only numeric values are submitted. Which control markup should you
use?
A.
<asp:TextBox ID=”txt1″ runat=”server”
CausesValidation=”true”
ValidationGroup=”Numeric” />
B.
<asp:TextBox ID=”txt1″ runat=”server”
EnableClientScript=”true”
ValidationGroup=”Numeric” />
C.
<asp:TextBox ID=”txt1″ runat=”server” />
<asp:RegularExpressionValidator ID=”val1″
runat=”server”
ControlToValidate=”txt1″
ValidationExpression=”[0-9]*”
ErrorMessage=”Invalid input value” />
D.
<asp:TextBox ID=”txt1″ runat=”server” />
<asp:RegularExpressionValidator ID=”val1″
EnableClientScript=”true”
ControlToValidate=”txt1″
ValidationExpression=”[0-9]*”
ErrorMessage=”Invalid input value” />
Explanation:
JavaScript executes as users enter and leave the focus of the controls on your page. Client-side
validation is turned on by default. You can turn it off for specific validation controls by setting the
EnableClientScript property to false.
CHAPTER 5 Input Validation and Site Navigation
Lesson 1: Performing Input Validation
Client-Side Validation (page 231)