Custom validation for text field
ATech created the topic: Custom validation for text field
Hi,
I would like to have an alphanumeric only text field. Is there a place for me to put the regular expression like
^[a-zA-Z0-9]$?
Thanks!
Please Log in or Create an account to join the conversation.
7 years 6 months ago
Agapi G. replied the topic: Custom validation for text field
Greetings! Thanks for posting your question!
There is surely a way to add the validation code. Please add a new Simple text field to your form and make sure Validation option is enabled. A new option will appear, titled Regular Expression please add your pattern to that input.
There are also some built-in validations, that you might find useful, so feel free to take a look.
Thanks! Have a wonderful day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
7 years 6 months ago
ATech replied the topic: Custom validation for text field
Thanks Agapi!
I couldn't find the "Validation" Option. Are you talking about the "Required field" checkbox or there is a separate one?
Also, where do I find the list of the built-in validations?
Thanks!
Please Log in or Create an account to join the conversation.
7 years 6 months ago
Agapi G. replied the topic: Custom validation for text field
Hello!
Please check this animated screenshot:
goo.gl/oyd8AV
I have shown this setting in it. Also please note, that in case you have an older version of the product, the option should be titled simply Regular Expression.
Thank you! Have a great day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
7 years 6 months ago
ATech replied the topic: Custom validation for text field
I just realized that I posted in the the wrong forum. I am using Joomla instead, please let me know the Joomla way. I don't see that option
Thanks!
Please Log in or Create an account to join the conversation.
7 years 6 months ago
Agapi G. replied the topic: Custom validation for text field
Hey!
Unfortunately this option is not available in Joomla Form Maker. But you can add a few lines of custom Javascript code and add your pattern there. Here's a Stackoverflow link, which will be useful for you:
goo.gl/qkDclv
Please add the code to Javascript tab of Form Options of your form.
Thank you! Have a great day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
7 years 6 months ago
ATech replied the topic: Custom validation for text field
Here's my form and I want to validate if the Customer PO# is alphanumeric .
www.alpha.ca/alphatmp/special-pick-up-and-delivery-instruction
I have added the validation in the before_submit() function but it does not seem to work.
Below is what I have:
function before_submit()
{
var Validatevalue = wdformjQuery("#wdform_1_element12").val();
if (/^([a-zA-Z0-9])$/.test(Validatevalue)){
return true;
} else {
alert('Invalid Customer PO#. ');
return false;
}
}
And I call the before_submit() function on the submit button.
Can you please advise! Thanks!
Please Log in or Create an account to join the conversation.
7 years 6 months ago
Agapi G. replied the topic: Custom validation for text field
Hey!
Probably having the validation on keyup would do the trick. Please try this code instead:
$( document ).ready(function() {
$('#wdform_1_element12').keyup(function() {
var inputVal = $('#wdform_1_element12').val();
var characterReg = /^([a-zA-Z0-9])$/;
if(!characterReg.test(inputVal)) {
alert ("Please enter a valid value for Customer PO#.");
}
}
});
Also you need to add this outside of the built-in functions. Please try and let me know if this works.
Thanks! Have a nice day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
7 years 6 months ago