07-11-2024
02:12 AM
- last edited on
07-11-2024
02:40 AM
by
shazubai
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>
07-15-2024 01:01 AM
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.
08-12-2024 11:33 AM
Any solution for this?
08-14-2024 12:19 AM
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>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide