cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
739
Views
0
Helpful
3
Replies

Guest Self-registration How to Validate Phone Number Length in ISE 3.1

ahmedsaif
Level 1
Level 1

Tried following the article below to validate the phone number in a self-registration form for ISE 3.1 but something seems to fail. The length validation works initially as expected when entering the data in the input field and all looks good. However, when "Register" button is clicked the same filed starts throwing error. Is there a deafult validation that kicks-in and overrides the custom validation? 

ISE Guest Self-Registration form working with phone numbers - Cisco Community

Using the below script:

<script>

(function(){

jQuery(document).ready(function() {

    jQuery("#guestUser\\.fieldValues\\.ui_phone_number").attr("placeholder", "1234567890");

    jQuery("#guestUser\\.fieldValues\\.ui_phone_number").attr("type", "number");

        setTimeout(function(){

            cisco.ise.validation.setPhoneRegex (/^[0-9]{10}$/);

            cisco.ise.validation.setPhoneNumberMessage("Please provide your phone number in format XXXXXXXXXX");

        }, 100);

    });

})

();

</script>

 

3 Replies 3

Arne Bier
VIP
VIP

I'm not a jQuery/JavaScript programmer, but the function called setTimeout appears to have an argument of 100. According to this link, the value is in milliseconds. And on that same link you provided, the other examples use different values. Perhaps try 2000 or greater.  

 

Any solution for this?

I have solved with this script:

 

<script>
setTimeout(function(){

$.validator.addMethod("phoneNumber", function(value, element) {

var filter = /^[0-9]{9}$/;

if (filter.test(value)) {

return true;
}
else {

if(value.startsWith("+")) {

return true;

}
else {

return false;

}
}

}, 'Incorrect length of the phone number.');

 

$("#guestUser\\.fieldValues\\.ui_phone_number").rules("add",{phoneNumber:true,
phone:false});
},500);
</script>