Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
Nível 1
Nível 2
Faça login na Comunidade
Faça logon para exibir todas as medalhas
Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
I am creating a form that requires City, State and Zip. I need to make sure that users do not put City, State and Zip into the City field; which someone so nicely pointed out to me as a problem with the form. Anyway, what I am looking for is a way to force the user to only be able to enter alpha characters into the City text field. I had glanced at the "Validation Patterns" OOTB functionality but I could not find anything listed that would complete the requirement.
Thank you,
Solucionado! Ir para a Solução.
You can use regular expressions in the change:event of the textfield to limit the characters that can be typed in.
Will allow only digits and the characters A-Z and a-z
if (xfa.event.newText.match(/[^A-Za-z0-9]/))
{
xfa.event.change = "";
}
You can use regular expressions in the change:event of the textfield to limit the characters that can be typed in.
Will allow only digits and the characters A-Z and a-z
if (xfa.event.newText.match(/[^A-Za-z0-9]/))
{
xfa.event.change = "";
}
Thank you very much for the quick response to this question. I used your example and tweaked it just a little to make it allow only alpha characters and then to convert to upper case. The result that worked was this.
if
(xfa.event.newText.match(/[^A-Za-z]/))
{
xfa.event.change
= "";
}
xfa.event.change
= xfa.event.change.toUpperCase();
Thank you again for your help.
I did run into one issue in the fact that I cannot add a space now to allow for City names that have more than one word. What can I add to allow this space in the field?
Thank you,
Visualizações
respostas
Total de curtidas
Adding a space to the regualar expression will do the trick.
if (xfa.event.newText.match(/[^A-Za-z0-9 ]/))
{
xfa.event.change = "";
}
this code won't work with my dynamic xml form. Is there a different code to make this work for dynamic xml forms? This works only if my form is saved as a static pdf.
Visualizações
respostas
Total de curtidas
Hey,
How do i avoid space as my first character? I'd want to restrict user from entering space as my first charcter in a text field.
Thanks,
Radhika
Visualizações
respostas
Total de curtidas
Actually want to avoid special characters(including space) at my first character.
Any help will be much appreciated.
Thanks,
Radhika
Visualizações
respostas
Total de curtidas
Hi,
I was able to achieve this with the below in my change event:
if(xfa.event.newText.charAt(0).match(/[ `~!@#$%^&*()-_={}|:;."<>,\\\[\]]/g))
{
xfa.event.change = "";
}
But the above restricts numeric also from entering at first position i am assuming this is happening cuz im using chartAt() which probably checks only for string.
I need the user to enter either alphabet or numeric at my first character.
Please Help.
Visualizações
respostas
Total de curtidas
this should do the trick.
if (!xfa.event.newText.charAt(0).match(/[a-zA-Z0-9]/g)) {
xfa.event.change = "";
}
I did try the code above few days back and it did not work
It did today!
I am writing the below in the exit event too, cuz the above code holds good only when the user is typing.
if (!xfa.this.rawValue.charAt(0).match(/[a-zA-Z0-9]/g)) {
this.rawValue = null;
xfa.host.setFocus(this);
}
Thanks a lot radzmar!
Visualizações
respostas
Total de curtidas
Hi all,
I'm using the script below to force numbers only for a phone number field, but it allows the user to press the parentheses and dash characters into the field, perhaps related to auto-fill on the field. Is there any way of preventing this?
if (xfa.event.newText.match(/[^0-9]/)) {
xfa.event.change = "";
}
Visualizações
respostas
Total de curtidas
Hi all,
In addition to my question above, I have another: I have an e-mail field where all users will be entering the same domain after the "@". Is there a way to automatically replace the "@" with "@domain.com"? I have used the code below (and other variations of it, using quotation marks, etc.) and haven't been able to make it work:
if (xfa.event.newText.match(/[@]/)) {
xfa.event.change = "@domain.com";
}
Great appreciate any help!
Visualizações
respostas
Total de curtidas
You can use something like:
if (xfa.event.newText.match(/[\ba-zA-Z0-9._-]+@{1}/g)) {
xfa.event.change = "@domain.com";
}
Visualizações
respostas
Total de curtidas
Thanks, Radzmar, it works! But there's one little issue -- if I press the Backspace key to make a correction, or even type in any other letters, it adds another "@domain.com" with every keystroke. The only way I have found to get around it is to manually select the entire portion containing all the ampersands and then press Delete. Any way to solve that?
Visualizações
respostas
Total de curtidas
I figured it out! It just needs to be like this:
//replace @ with "@domain.com"
if (xfa.event.change == "@") {
xfa.event.change = "@domain.com";
}
So it will generate the suffix string only when you press "@", and it allows corrections without duplication, etc.
it works fine for dynamic forms
Visualizações
respostas
Total de curtidas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas