Quantcast
Channel: LivePerson Connect : Popular Discussions - All Communities
Viewing all articles
Browse latest Browse all 2324

Restricting Phone Number Field

$
0
0

Hi all,

 

I have been provided some assistance in restricting a phone number field in a pre-chat survey.  However, when I add this to my PCS header, launching the PCS for a chat, the form is completely blank, basically the questions/form fields are all missing.

 

Thoughts?

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript" ></script>

 

<script type="text/javascript">

function validate(phone) {

    // International Phone number - +011 972 9 123 4567

    var intRegex = /^\+([0-9]{1,3} ?)(?:[0-9] ?){6,14}[0-9]$/;

     

    // U.S. Phone number

    var usRegex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;

 

    if (intRegex.test(phone) || usRegex.test(phone)) {

          return true;

     } else {

      // Invalid international phone number

       alert("Please enter a valid phone number!");

       return false;

    }

}

</script>

 

<!-- The phone field ID is dynamically created by the survey. In the code below the phone field element ID is "q4". However, in your survey it may be a different value. In order to find the phone field's element ID, follow these steps:

1.    go to the Visitor Experience -> Chat -> Window Editor tab.

2.    Select the window that represents the window skin (i.e., classic, modern, engagement).

3.    In the Window Type dropdown, choose "Prechat Survey Window".

4.    At the bottom, click the "Preview" button

5.    After the window opens, right click in the window and select "View frame source".

6.    In the source code, find the "phone number" label and take note of the "input" element's ID that represents the phone number. For Example:

<input tabindex="5" type="text" name="ude!856385" id="q4" size="24" value="" maxlength="900" />

 

This is the value you'll assign to the phoneEl variable in the below code

-->

 

<script type="text/javascript">

$('#submitGallery a', window.parent.document).click(function(){

   var phoneEl= document.getElementById('q4').value;

     //if(phoneEl){

          try{

              if(validate(phoneEl)){

                   parent.checkForm();

              }

          }catch(e){alert(e);}

     //}

});



Viewing all articles
Browse latest Browse all 2324

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>