validation and input formatting

11

Upload: neha-kaurav

Post on 22-Jan-2018

111 views

Category:

Presentations & Public Speaking


0 download

TRANSCRIPT

VALIDATIONS AND INPUT FORMATTING

NEHA KAURAVSHIVA MISHRA

CLASS:BCA 3rd SEM.

• You must have noticed in many applications that when you enter something incorrectly or when you leave the field blank, it warns you with a message. This is called validation.

More precisely, when you leave the text field and move to another control, you get a warning message and the input focus goes back to the previous field.

In short, validation tells the user to enter valid data.

• The first level of validation is at the field level. This is the place where you can make sure the user is entering the right characters in the field, entering the data into the field in the proper format, and entering a valid value based on a list of possible choices.

• Form-level validation is an essential part of designing a good validation scheme for your form. Although many input errors can be caught and corrected at the field level, there are several validation steps that can only be performed well at the form level.

• Although field-level validation is performed at the time a key is pressed or at the time a field loses focus, form-level validation is performed at the time the user presses Enter, or clicks the OK or Save button.

• These are validations that are done after the user has entered all data, but before any attempt is made to store the values to a data table.

• The MaskedEdit control is used to prompt users for data input using a mask pattern. You can also use it to prompt for dates, currency, and time, or to convert input data to all upper- or lowercase letters.

• The input mask prevents users from entering invalid characters into the control. If the user attempts to enter a character that conflicts with the input mask, the control generates a ValidationError event.

• The MaskedEdit control is a bound control and can be used with a data control to display or update field values in a data set.

• The Mask property determines the type of information that is input into the MaskedEdit control. The Mask property uses characters such as the pound sign (#), backslash (\), comma (,), and ampersand (&) as placeholders that define the type of input. The following table lists all the characters you can use to set the Mask property:

Mask

character

Description

# Digit placeholder.

. Decimal placeholder. The actual character used is the one specified as the decimal placeholder in your

international settings. This character is treated as a literal for masking purposes.

, Thousands separator. The actual character used is the one specified as the thousands separator in your

international settings. This character is treated as a literal for masking purposes.

: Time separator. The actual character used is the one specified as the time separator in your international

settings. This character is treated as a literal for masking purposes.

/ Date separator. The actual character used is the one specified as the date separator in your international

settings. This character is treated as a literal for masking purposes.

\ Treat the next character in the mask string as a literal. This allows you to include the '#', '&', 'A', and '?'

characters in the mask. This character is treated as a literal for masking purposes.

& Character placeholder. Valid values for this placeholder are ANSI characters in the following ranges: 32-126

and 128-255.

> Convert all the characters that follow to uppercase.

< Convert all the characters that follow to lowercase.

A Alphanumeric character placeholder (entry required). For example: a z, A Z, or 0 9.

A Alphanumeric character placeholder (entry optional).

9 Digit placeholder (entry optional). For example: 0 9.

C Character or space placeholder (entry optional).

? Letter placeholder. For example: a z or A Z.

Literal All other symbols are displayed as literals; that is, as themselves.

Private Sub Command1_Click()If MaskEdBox1.ClipText = "" Then

MsgBox "insert the value of date"MaskEdBox1.SetFocus

ElseIf Option1.Value = False ThenMsgBox "first select the option"

ElseMsgBox "Hello Class"End

End IfEnd Sub

Private Sub Form_Load()Option1.Value = FalseEnd Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii < 65 Or KeyAscii > 90 Then

If (KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <> 8 And KeyAscii <> 32 ThenKeyAscii = 0

End IfEnd IfEnd Sub

Private Sub Text1_LostFocus()If Text1.Text = "" Then

MsgBox "first enter the name"Text1.SetFocus

End IfEnd Sub