Are you human? - Page 2 - Post ID 285045

User 187934 Photo


Senior Advisor
20,239 posts

I updated my form.
https://ericrohloff.com/coffeecup/ccfor … /form.html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
// version 2
function Cap_Words(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
jQ( document ).ready(function() {
jQ('input[name^="Name"]').on('keydown', function(event) {
jQ('input[name^="Name"]').each(function(){
if(jQ(this).val()!=''){
jQ(this).val(Cap_Words(jQ(this).val()));
}
});
});

jQ(':submit').hide();
jQ("input[name='human']").keyup(function(){

if (!jQ(this).val().match(/^[6]+$/) || jQ(this).val() == "") {

jQ(':submit').hide();
jQ(':submit').attr('disabled', 'disabled');
}else{
jQ(':submit').show('slow');
jQ(':submit').removeAttr('disabled');
}
});



jQ('input[name="PhoneNum"]').on("keyup paste change", function() {
var input = this.value.replace(/[^0-9\(\)\s\-]/g, "");
var inputlen = input.length;
var numbers = this.value.replace(/\D/g,'');
var numberslen = numbers.length;
var newval = "";

for(var i=0;i<numberslen;i++){
if(i==0) newval="("+numbers[i];
else if(i==3) newval+=") "+numbers[i];
else if(i==6) newval+="-"+numbers[i];
else newval+=numbers[i];
}

if(inputlen>=1&&numberslen==0&&input[0]=="(") newval="(";
else if(inputlen>=6&&numberslen==3&&input[4]==")"&&input[5]==" ") newval+=") ";
else if(inputlen>=5&&numberslen==3&&input[4]==")") newval+=")";
else if(inputlen>=6&&numberslen==3&&input[5]==" ") newval+=" ";
else if(inputlen>=10&&numberslen==6&&input[9]=="-") newval+="-";

jQ(this).val(newval.substring(0,14));
});

jQ('input[name="human"]').on('blur', function() {
var Value = jQ(this).val();
if(Value == ''){Value='0';}
var Orig_t = jQ(this).next('span').text();
var New_Ent = Orig_t.slice(0, -1);
jQ(this).next('span').text(New_Ent+Value);
});

});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2902462 Photo


Registered User
45 posts

Eric I have find an issue with my form and your code. As I have said before I have a check box in the form that is required. What I found is with your code running. If I do not check the box and answer the human question right or wrong I get an error on the human question. This leaves the user not knowing what they got wrong because the answer to the human question could be right. I tried looking for away to test the check box for an error. I thought this might let be put out a ( Form-error ) but no luck.
Here I am needing help again.
David Doyle
User 187934 Photo


Senior Advisor
20,239 posts

Can you share a link to the form?
Maybe your .fb file and your fdp file.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2902462 Photo


Registered User
45 posts

link to form
telgogolf.coffeecup.com/my-forms/league signup form
or
http://telgogolf.coffeecup.com/my%2Dfor … /form.html
David Doyle
User 187934 Photo


Senior Advisor
20,239 posts

You changed the pattern of the human input from pattern="[6]" to pattern="/^[6]+$/". Looks like that's causing the issue.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2902462 Photo


Registered User
45 posts

Hello Eric
I have put all of the scrips that you made into one file so I can use it on all of my forms. On my computer they seem to work but on my cell phone they don't. All of the letters that are typed are displayed along with the changes your script makes to them. Can they all be put into one file? Can the Submit button be made to display but dimmed out and not work until the question is answered? Can the error from putting in the wrong answer be reset and hidden when the user clicks any where on the page? attached is a file with all of the codes together.
Thank you for any help you can provide.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">

var jQ = $.noConflict(true);
// version 2
function Cap_Words(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
var jQ = $.noConflict(true);
// version 1
jQ(document).ready(function () {
jQ('input[name="Company"]').keyup(function() {
jQ(this).val(jQ(this).val().toUpperCase());
});
});
jQ( document ).ready(function() {
jQ('input[name^="Name"]').on('keydown', function(event) {
jQ('input[name^="Name"]').each(function(){
if(jQ(this).val()!=''){
jQ(this).val(Cap_Words(jQ(this).val()));
}
});
});

jQ(':submit').hide();
jQ("input[name='human']").keyup(function(){

if (!jQ(this).val().match(/^[6]+$/) || jQ(this).val() == "") {

jQ(':submit').hide();
jQ(':submit').attr('disabled', 'disabled');
}else{
jQ(':submit').show('slow');
jQ(':submit').removeAttr('disabled');
}
});

jQ('input[name="PhoneNum"]').on("keyup paste change", function() {
var input = this.value.replace(/[^0-9\(\)\s\-]/g, "");
var inputlen = input.length;
var numbers = this.value.replace(/\D/g,'');
var numberslen = numbers.length;
var newval = "";

for(var i=0;i<numberslen;i++){
if(i==0) newval="("+numbers[i];
else if(i==3) newval+=") "+numbers[i];
else if(i==6) newval+="-"+numbers[i];
else newval+=numbers[i];
}

if(inputlen>=1&&numberslen==0&&input[0]=="(") newval="(";
else if(inputlen>=6&&numberslen==3&&input[4]==")"&&input[5]==" ") newval+=") ";
else if(inputlen>=5&&numberslen==3&&input[4]==")") newval+=")";
else if(inputlen>=6&&numberslen==3&&input[5]==" ") newval+=" ";
else if(inputlen>=10&&numberslen==6&&input[9]=="-") newval+="-";

jQ(this).val(newval.substring(0,14));
});

jQ('input[name="human"]').on('blur', function() {
var Value = jQ(this).val();
if(Value == ''){Value='0';}
jQ(this).next('span').append(' '+Value);
});

});

jQ(document).ready(function () {
jQ('input[name="First-N"],input[name="Last-N"],input[name="City"]').on('keydown', function(event) {
if(jQ('input[name="First-N"]').val()!=''){
jQ('input[name="First-N"]').val(Cap_Words(jQ('input[name="First-N"]').val()));
}
if(jQ('input[name="Last-N"]').val()!=''){
jQ('input[name="Last-N"]').val(Cap_Words(jQ('input[name="Last-N"]').val()));
}
if(jQ('input[name="City"]').val()!=''){
jQ('input[name="City"]').val(Cap_Words(jQ('input[name="City"]').val()));
}
});

});

jQ(document).ready(function () {
jQ('input[name^="Contact"]').on('keydown', function(event) {
jQ('input[name^="Contact"]').each(function(){
if(jQ(this).val()!=''){
jQ(this).val(Cap_Words(jQ(this).val()));
}
});
});
});


</script>
David Doyle
User 187934 Photo


Senior Advisor
20,239 posts

Give this a try.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
// version 3
function Cap_Words(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
jQ( document ).ready(function() {
jQ('input[name^="Name"]').on('keydown', function(event) {
jQ('input[name^="Name"]').each(function(){
if(jQ(this).val()!=''){
jQ(this).val(Cap_Words(jQ(this).val()));
}
});
});
jQ(':submit').attr('disabled', 'disabled');

jQ("input[name='human']").keyup(function(){

if (!jQ(this).val().match(/^[6]+$/) || jQ(this).val() == "") {
jQ(':submit').attr('disabled', 'disabled');
}else{
jQ(':submit').removeAttr('disabled');
}
});

jQ('input[name="PhoneNum"]').on("keyup paste change", function() {
var input = this.value.replace(/[^0-9\(\)\s\-]/g, "");
var inputlen = input.length;
var numbers = this.value.replace(/\D/g,'');
var numberslen = numbers.length;
var newval = "";

for(var i=0;i<numberslen;i++){
if(i==0) newval="("+numbers[i];
else if(i==3) newval+=") "+numbers[i];
else if(i==6) newval+="-"+numbers[i];
else newval+=numbers[i];
}

if(inputlen>=1&&numberslen==0&&input[0]=="(") newval="(";
else if(inputlen>=6&&numberslen==3&&input[4]==")"&&input[5]==" ") newval+=") ";
else if(inputlen>=5&&numberslen==3&&input[4]==")") newval+=")";
else if(inputlen>=6&&numberslen==3&&input[5]==" ") newval+=" ";
else if(inputlen>=10&&numberslen==6&&input[9]=="-") newval+="-";

jQ(this).val(newval.substring(0,14));
});

jQ('input[name="human"]').on('blur', function() {

var Value = jQ(this).val();
if(Value == ''){Value='0';}
var Orig_t = jQ(this).next('span').text();
var New_Ent = Orig_t.slice(0, -1);
jQ(this).next('span').text(New_Ent+Value);
});

});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2902462 Photo


Registered User
45 posts

Here is what I put together with all of the scripts that you wrote for me. They seem to work but not on my cell phone. On the cell phone the letters are double typed. I attached a file if it works. I put part of your code at the end of the file. Could you help me understand who it work. What I'm looking at is can't I just change the input name and the code will work just the same? I see many duplicate code on each different input. Can they be taken down to one line. Like at the being of each code you use this line
jQ(document).ready(function () {
Can this be used once and all of the other code snips are put after.
What is this line used for? <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Thank you for your help
Attachments:
David Doyle
User 187934 Photo


Senior Advisor
20,239 posts

Give this a try.
You can see how you can add the additional selectors instead of repeating code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
// version 4
function Cap_Words(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
jQ( document ).ready(function() {
jQ('input[name="Name"], input[name="Contact"], input[name^="P"], input[name="First-N"],input[name="Last-N"],input[name="City"]').on('keydown', function(event) {
jQ('input[name="Name"], input[name="Contact"], input[name^="P"], input[name="First-N"],input[name="Last-N"],input[name="City"]').each(function(){
if(jQ(this).val()!=''){
jQ(this).val(Cap_Words(jQ(this).val()));
}
});
});
jQ(':submit').attr('disabled', 'disabled');

jQ("input[name='human']").keyup(function(){

if (!jQ(this).val().match(/^[6]+$/) || jQ(this).val() == "") {
jQ(':submit').attr('disabled', 'disabled');
}else{
jQ(':submit').removeAttr('disabled');
}
});

jQ('input[name="PhoneNum"]').on("keyup paste change", function() {
var input = this.value.replace(/[^0-9\(\)\s\-]/g, "");
var inputlen = input.length;
var numbers = this.value.replace(/\D/g,'');
var numberslen = numbers.length;
var newval = "";

for(var i=0;i<numberslen;i++){
if(i==0) newval="("+numbers[i];
else if(i==3) newval+=") "+numbers[i];
else if(i==6) newval+="-"+numbers[i];
else newval+=numbers[i];
}

if(inputlen>=1&&numberslen==0&&input[0]=="(") newval="(";
else if(inputlen>=6&&numberslen==3&&input[4]==")"&&input[5]==" ") newval+=") ";
else if(inputlen>=5&&numberslen==3&&input[4]==")") newval+=")";
else if(inputlen>=6&&numberslen==3&&input[5]==" ") newval+=" ";
else if(inputlen>=10&&numberslen==6&&input[9]=="-") newval+="-";

jQ(this).val(newval.substring(0,14));
});

jQ('input[name="human"]').on('blur', function() {

var Value = jQ(this).val();
if(Value == ''){Value='0';}
var Orig_t = jQ(this).next('span').text();
var New_Ent = Orig_t.slice(0, -1);
jQ(this).next('span').text(New_Ent+Value);
});

jQ('input[name="Company"]').keyup(function() {
jQ(this).val(jQ(this).val().toUpperCase());
});

});
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2902462 Photo


Registered User
45 posts

Hello Eric
I have an issue with the code when I tested the forms on my cell phone. After typing 2 letters they will repeat.
Like TE when you type the next letter you get TETE
www.telgogolf.com/contact.html
Any ideas
David Doyle

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.