Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
validation code needed
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
I have a web edit text box which should not accept ^ and ~.Also the minimum characters that it should accept should be 3.
It should accept all alphanumeric characters except ^ and ~.

Please provide me the code for this in QTP.
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Check if this is useful.

Code:
NegativeTest Dialog("Login").WinEdit("Agent Name:"),"^"
Public Function NegativeTest(objWebEdit,Input)
    If Input = " ~" Then
          'Logic to enter the data and validate the message
          objwebEdit.Set "~"
          msgbox "Input as ~"
    ElseIf Input = "^" Then
         'Logic to enter the data and validate the message
         objWebEdit.Set "^"
         msgbox "Input as ^"
    ElseIf Len(Input)<4 Then
         'Logic to enter the data and validate the message.
         objWebEdit.Set Input
         msgbox "Input less than 4 Charecters"
    Else
            msgbox "Please send the proper input."
    End If
End Function

Thanks,
SUpputuri
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Thankx for the reply.
Just wantd to know if it can be solved using regular expressions?
Also,this text box should not allow strings such as
anita^,~rohan.
Does the above code run successfuly for these examples too.?
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Nats,

Yes we can handle this using Regular expression too. You have to create a regular expression object and then create a pattern such that it will exclude the characters (~,^).

Yeah Script which I have provided will work for anita^,~rohan by using the instr function rather than doing direct validation for the characters. please find the below updated code.
Code:
NegativeTest Dialog("Login").WinEdit("Agent Name:"),"ani~ta"
Public Function NegativeTest(objWebEdit,Input)
    If Instr(Input, "~") >0 Then
          'Logic to enter the data and validate the message
          objwebEdit.Set Input
          msgbox "Input as " & Input
    ElseIf Instr(Input, "^") >0 Then
         'Logic to enter the data and validate the message
         objWebEdit.Set Input
         msgbox "Input as " & Input
    ElseIf Len(Input)<4 Then
         'Logic to enter the data and validate the message.
         objWebEdit.Set Input
         msgbox "Input less than 4 Charecters"
    Else
            msgbox "Please send the proper input."
    End If
End Function
Thanks,
SUpputuri
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago At 
Hey thanx a llot!!Wink
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
@nats: Please make sure to read the posting guidelines and post on appropriate sub-forum.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  XML input data validation with data in oracle tables using webservice smtripathi99 0 2,406 12-11-2012, 01:32 PM
Last Post: smtripathi99
  WordPress CMS validation with the website sanrag 0 2,117 11-22-2011, 12:11 PM
Last Post: sanrag
  Help needed to automate JavaTree object guin.anirban 0 1,928 07-16-2011, 11:20 PM
Last Post: guin.anirban
  validation tables and column in a oracle database ajayr1982 0 2,684 04-20-2011, 10:04 AM
Last Post: ajayr1982
  Page Validation for Web Application learnqtsw 2 6,637 10-08-2010, 04:15 PM
Last Post: A.Saini

Forum Jump:


Users browsing this thread: 1 Guest(s)