cancel
Showing results for 
Search instead for 
Did you mean: 

Input field validations

Former Member
0 Kudos

Hi Experts,

I have a scenario, wherein, i need to fetch the input from the user using input field. The input field should be of 3 character length and the first character should be + or - and the last two digits should be numeric. eg. +12 or -45.

So, what should be the validations, to be done on that input field. If he gives the input in some other combination like 1 or ++2, error message should be populated. Please, send me the appropriate code.

Thanks & Regards,

Akshay.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi akshay0222.

In this case i will do the validation in the method WDDOBEFOREACTION of the view where the inputfield is displayed. This method is executed in every user action, so the validation will always be executed.

For the validation I'll storage the value of the inputfield in a character var of length 3, and the code as follows:



* Read value of input field from context previously and storage in lv_value.

  IF ( lv_value(1) NE '+' AND lv_value(1) NE '-' )
    OR lv_value+1(2) CN '1234567890'.

*   ERROR MESSAGE

  ENDIF.

Regards,

Pablo.

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

I assume you need to handle those inputs explicitly...

define the data element in se11, check the sign(check box) so that i can accept the SIGNS( + or -).

now define the attribute with that data element.

bind that attribute to that input field.

on user actions say "save" or "submit" or any action...

read the attibute ( you have a wixard to do that)...

read the value in the attribute

I assume if he give ++2..then system will automatically raises the error, to give a valid input...

i guess 1 needs to be considered as positive value, how ever you want to raise an error...

as of now you have read the value...

check whether its has a + sign...