- Posts: 256
- Thank you received: 37
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
regular expression issue
- first
- Topic Author
- Offline
- Elite Member
Less
More
9 years 2 months ago #116526
by first
Survey Designer and Programmer
regular expression issue was created by first
HI , Need urgent help..
regex test (emailPat) in below code is working fine when I am injecting code in browser through browser console but it doesnt work after placing it in LS question text. Is there any special way of using regular expression in LS?
regex test (emailPat) in below code is working fine when I am injecting code in browser through browser console but it doesnt work after placing it in LS question text. Is there any special way of using regular expression in LS?
Code:
var $emailBoxes = $('#answer559779X556X128541_a,#answer559779X556X128542_a'); var emailPat = /^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/ $('#movenextbtn').on('click',function(){ var errorState = false; $emailBoxes.each(function(){ var tempEmailInput = $.trim($(this).val()); if(tempEmailInput != '' && emailPat.test(tempEmailInput) == false){ //Input is not empty and Do not pass email validation test $(this).css('background-color','red'); $('span.questionhelp:first').text('Please enter valid email id').css('color','red'); errorState = true; } }); if(errorState){ return false; } });
Survey Designer and Programmer
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10635
- Thank you received: 3699
9 years 2 months ago #116531
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic regular expression issue
With the advent of Expression Manager, you cannot have curly braces in regexes in the question source (I know, I know, don't get me started on that again).
Try defining the emailPat var in template.js instead of in your question.
Try defining the emailPat var in template.js instead of in your question.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: first
The topic has been locked.
- first
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 256
- Thank you received: 37
9 years 2 months ago #116532
by first
Survey Designer and Programmer
Replied by first on topic regular expression issue
thank you TJ , you are always very helpful..
Survey Designer and Programmer
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 2 months ago #116635
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic regular expression issue
The best approach to validate email addresses at Limesurvey is using Limesurvey's expression manager.
This is explained at this blog post: www.limesurvey-consulting.com/how-to-val...esses-at-limesurvey/
This is explained at this blog post: www.limesurvey-consulting.com/how-to-val...esses-at-limesurvey/
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The following user(s) said Thank You: first
The topic has been locked.