message (Wrong telephon number | Community
Skip to main content
Level 2
December 22, 2018
Solved

message (Wrong telephon number

  • December 22, 2018
  • 4 replies
  • 3144 views

how cold I creat Nnumericfield that must fill with correct phone number

the correct number that is :

71x-xxx-xxx

or : 77x-xxx-xxx

or  73x-xxx-xxx

If  the number had entered wrongly the message that appear is

( Wrong telephone number !!)

I need the code and where I must put it ??

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mayank_Gandhi

try this

if(this.rawValue!=null && this.rawValue!=""){

var str = this.rawValue;

var twoDigits = str.slice(0,2);

//xfa.host.messageBox(twoDigits);

if(twoDigits=="71" || twoDigits=="77" || twoDigits=="70" || twoDigits=="73"){

   //xfa.host.messageBox("Right number!");

    if(str.length!=9)

xfa.host.messageBox("Your number should be of 9 digits");

}

else{ xfa.host.messageBox("worng phone number");

}

}

4 replies

Mayank_Gandhi
Adobe Employee
Adobe Employee
December 26, 2018

Have you tried setting patterns in the numeric field/ text field?

Level 2
December 27, 2018

Nathan Brunaugh <nathan@truetechtroubleshooting.com

Nathan Brunaugh gave  me the code ..and it worked perfectly:

========================the code =============

if(this.rawValue!=null && this.rawValue!=""){

var str = this.rawValue;

var twoDigits = str.slice(0,2);

//xfa.host.messageBox(twoDigits);

if(twoDigits=="71" || twoDigits=="77" || twoDigits=="70" || twoDigits=="73"){

   //xfa.host.messageBox("Right number!");

}

else{ xfa.host.messageBox("worng phone number");

}

}

============================

BUT there is another Q :

the correct phone number must includes (9) numbers  ( 7## ### ### )

if you entered more or less than 9 numbers the same message  has been showed

HOW can I right this code and where must put it ??

Mayank_Gandhi
Adobe Employee
Mayank_GandhiAdobe EmployeeAccepted solution
Adobe Employee
December 28, 2018

try this

if(this.rawValue!=null && this.rawValue!=""){

var str = this.rawValue;

var twoDigits = str.slice(0,2);

//xfa.host.messageBox(twoDigits);

if(twoDigits=="71" || twoDigits=="77" || twoDigits=="70" || twoDigits=="73"){

   //xfa.host.messageBox("Right number!");

    if(str.length!=9)

xfa.host.messageBox("Your number should be of 9 digits");

}

else{ xfa.host.messageBox("worng phone number");

}

}

Level 2
December 29, 2018

yyyeesss!! thanks alot .. this is what I want