R
Ronan40060
Dear Friends
I need to write a small peice of code a string "payment_code" which
comes
populated from a text field , should contain only 0-9,A-Z,a-z,Space '
',Hyphen '-',Full stop '.',Comma ',',Plus '+'
Characters other than these will not be allowed
If a user enters characters other than the mentioned above , the
alert
message should be displayed
This requirement is a part of Reverse Enginnering project that we are
doing , the current script is written to validate above is in PB and
it needs to be written in Java
I also had writing the same in Java Script but then due to the
framework of our project , it demands to be written in Java
typical steps would be
1 declare variables of integer types
var li_len, li_idx, li_value
2 declar variables of string types
var ls_tmp_string, ls_char
3 Remove the white spaces from as_payment_code string and store it in
ls_tmp_string
4 Calulate the length of the string variable ls_tmp_string and store
it in li_len
li_len = ls_tmp_string.length;
5 For li_idx = 1 to li_len
get the substring and store it in ls_char
var ls_char = ls_tmp_string.substr(li_idx,1);
Check ls_char for 0-9,A-Z,a-z,Space ' ',Hyphen '-',Full stop
'.',Comma ',',Plus '+'
if it cotains any of the above values then continue
else
show a pop-up and display message ( "Error!", "Invalid character: "
+ ls_char ) and return false
Thank you
I need to write a small peice of code a string "payment_code" which
comes
populated from a text field , should contain only 0-9,A-Z,a-z,Space '
',Hyphen '-',Full stop '.',Comma ',',Plus '+'
Characters other than these will not be allowed
If a user enters characters other than the mentioned above , the
alert
message should be displayed
This requirement is a part of Reverse Enginnering project that we are
doing , the current script is written to validate above is in PB and
it needs to be written in Java
I also had writing the same in Java Script but then due to the
framework of our project , it demands to be written in Java
typical steps would be
1 declare variables of integer types
var li_len, li_idx, li_value
2 declar variables of string types
var ls_tmp_string, ls_char
3 Remove the white spaces from as_payment_code string and store it in
ls_tmp_string
4 Calulate the length of the string variable ls_tmp_string and store
it in li_len
li_len = ls_tmp_string.length;
5 For li_idx = 1 to li_len
get the substring and store it in ls_char
var ls_char = ls_tmp_string.substr(li_idx,1);
Check ls_char for 0-9,A-Z,a-z,Space ' ',Hyphen '-',Full stop
'.',Comma ',',Plus '+'
if it cotains any of the above values then continue
else
show a pop-up and display message ( "Error!", "Invalid character: "
+ ls_char ) and return false
Thank you