Hi Guillaume,
I can think of two ways to solve this
1) User Education
You could try adding a placeholder on the service catalog form to make sure they fill it in a certain format. You can configure this under Admin -> Service Catalog
2) Validation
We could try writing a code snippet on the end user portal to make sure the field only accepts only the email format.
Hi,
Thank you for quick reply !
We already tryed the user education, and unfortunately this is not 100% reliable.
The second option could be very nice !
May you keep me informed about this ?
Best regards,
Hi Guillaume,
Yes, user education isn't always reliable unfortunately :(
I have a code snippet that could potentially work. Let's continue the conversation over email and post the solution back here if it works?
Hi Guillaume,
It was fun working with you to solve this problem. Sharing the code snippet here for wider audience. Happy to help anyone solve similar problems. I've added comments in the code to explain the functionality.
This needs to be placed inside Page Layout under the Helpdesk Rebranding section
jQuery(document).ready(function(){ validateEmail() //Declaring global variable var isEmailCheck //targeting the submit button jQuery(".pull-right .btn-red").on("click", function(){ validateEmail() console.log(validateEmail()) if(validateEmail() == "Valid") { // no action required - form will be submitted } else { //shows alert message event.stopPropagation() event.preventDefault() alert("Please Enter your email in the right format") } }) //end on click function validateEmail() { //ID of the email address field var fldName = "#requested_item_values_234_requested_item_value_attributes_mme_profil_que__same_profile_as_email_25000021483" //A span container to hold the error message jQuery(fldName).parent().append("<span id = 'errorMsg'> </span>") //Any time a user finishes typing their email jQuery(fldName).on("blur", function(){ var ifEmail = jQuery(fldName).val().indexOf("@") //Check if the string has @ to confirm if it's an email address var ifSpace = jQuery(fldName).val().trim().indexOf(" ") //Check if the string has any unnecessary spaces console.log(ifEmail + " " + ifSpace) if((ifEmail != -1) && (ifSpace == -1)) { jQuery("#errorMsg").text("Valid Email Format") isEmailCheck = "Valid" } //end if else { jQuery("#errorMsg").text("Invalid Email Format") isEmailCheck = "Invalid" } }) //end blur return isEmailCheck } //end function }) //end ready
Hi Sanjeev!
Thanks a lot for your reactivity and efficiency.
That's nice to work with freshservice !
Regards,
Guillaume Leroy
Hello,
In the forms in the service catalog we ask user to write their email adress (and only email adress)
unfortunately 15% of users are not writting exactly an email adress. Sometimes they write : Here is my email adress : ...@...
Is it possible to force the user to enter only an email adress ?
This would be really nice for our cases !
Regards,