How to fix recaptcha error? - html

I have a sitekey and I want to reproduce the captcha locally. However, when I open the html it says invalid domain for sitekey.
this is the code in my html file:
<script type='text/javascript' src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form method="post" action="you cannot see this link">
<input type="text" placeholder="productcode_size" name="pid">
<input type="text" placeholder="productcode" name="masterPid">
<input type="hidden" value="1" name="Quantity">
<input type="hidden" value="" name="x-PrdRtt" id="captcha_val">
<input type="hidden" value="Add To Bag overlay" name="layer">
<input type="hidden" name="ajax" value="true">
<br>
<br>
<br>
<br>
<div style="opacity: 0.3" class="g-recaptcha" data-sitekey="you cannot see this sitekey"></div>
<br>
<div class="contionue-shopping-wrapper">
<form class="co-formcontinueshopping" action="You cannot see this link" method="post" id="dwfrm_cart_d0ffhvzsobkp">
<fieldset>
<button class="rbk-button-red button-primary bp-black right" type="submit" value="Continue Shopping" name="dwfrm_cart_continueShopping">
<span>Continue Shopping</span>
</button>
</fieldset>
</form>
</div>
</form>
<script>
check = setInterval(function() {
v = document.getElementById('g-recaptcha-response').value
if (v.length > 0) {
var r = '&x-PrdRtt='+v+'"">ATC Link</a>';
document.getElementById('captcha_val').value = v
var sz = document.getElementById('sz').value;
var pid = '?ajax=true&pid='+sz;
document.getElementById('hack').innerHTML = '<a href="'+document.forms[0].action+pid+r;
clearInterval(check);
}
}, 400)
</script>
</body>
</html>
Please can someone help me fix this? I want to be able to complete the captcha locally to extract the captcha response.

According to this page https://developers.google.com/recaptcha/docs/start
If you would like to use "localhost" for development,
you must add it to the list of domains.
so simply add "localhost" (or "127.0.0.1") , that should work for you.

Related

How to send data from a HTML form to a Google Apps Script

I am really new to google script and HTML and I am trying to create a program that accepts multiple inputs from a user using a HTML form, and when the user clicks submit, the data is stored inside a variable and can be used inside a .gs file from a .html . I have gotten the form to work but whenever I clicked "Submit" nothing occurs. After some troubleshooting, I think the problem is at my form_data() function. What I would like to know is how to compile the data inputs from the form and send it to my runsies() fucntion. Thank you in advance! Here is my HTML code below:
const ui = SpreadsheetApp.getUi();
function onOpen() {
ui.createAddonMenu()
.addItem('New Entry', 'newEntry')
.addToUi();
};
function newEntry() {
var html = HtmlService.createHtmlOutputFromFile("input")
.setWidth(750)
.setHeight(550);
//Display the dialog
var dialog = ui.showModalDialog(html, "External Organisations");
};
function runsies(info){
//Display the values submitted from the dialog box in the Logger.
Logger.log(info);
};
<html>
<head>
<!--Set the font of the form-->
<style>
body {font-family:Courier;}
</style>
</head>
<!--Main body design of the form-->
<body>
<!--Create text boxes for user input-->
<form action="" method="get" class="form-example">
</script>
<div class="form-example">
<label for="name"><b>Organisation: </b></label><br>
<input type="text" name="name" id= "txt1" style="border-radius:3px" required><br><br>
</div>
<div class="form-example">
<label for="email"><b>Email: </b></label><br>
<input type="text" name="email" id="txt2" style="border-radius:3px" required><br><br>
</div>
<div class="form-example">
<label for="phone"><b>Phone: </b></label><br>
<input type="text" name="phone" id="txt3" style="border-radius:3px" required><br><br>
</div>
<div class="form-example">
<label for="poc"><b>Point of Contact: </b></label><br>
<input type="text" name="poc" id="txt4" style="border-radius:3px" required><br><br>
</div>
<div class="form-example">
<label for="susmi"><b>SUSMI Contact: <b></label><br>
<input type="text" name="susmi" id="txt5" style="border-radius:3px" required><br><br>
</div>
<div class="form-example">
<label for="stats"><b>Status: <b></label><br>
<input type="text" name="stats" id="txt6" style="border-radius:3px" required><br><br>
</div>
<div class="form-example">
<label for="note"><b>Notes: </b><br><textarea rows="5" cols="50" id="multiLineInput" style="border:2px solid black;border-radius:3px">
</textarea></label><br><br>
</div>
<input type="button" value="Submit" onclick="form_data()">
<input type="button" value="Close" onclick="google.script.host.close()" />
<!--Once user clicks submit, compile info and send it to main .gs code-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function form_data(){
var info = [txt1,txt2,txt3,txt4,txt5,txt6,multiLineInput];
google.script.run.withSuccessHandler().runsies(info);
closeIt()
};
function closeIt(){
google.script.host.close()
};
</form>
</body>
</html>```
var info = [txt1,txt2,txt3,txt4,txt5,txt6,multiLineInput];
Your array is just a bunch of element id's if you want the data use `document.getElementById().value for the text boxes
Read about client to server communication google.script.run
javascript reference

How can I make a input that goes to a youtube video?

I'm trying to make an input that goes to a youtube video by entering a video ID. What I'm I doing wrong with this code?
<form method="get" action="http://www.youtube.com/embed/">
<input id="searchinput" type="text" placeholder="Enter Video ID" name="" value="">
<input type="hidden">
</form>
You don't necessary use a form like that.
You can use javascript to get value from input and change the page.
<head>
<script>
function goToYoutube(){
const id = document.querySelector("#searchinput").value;
location.href = "http://www.youtube.com/embed/" + id;
}
</script>
</head>
<body>
<input id="searchinput" type="text" placeholder="Enter Video ID" name="" value="">
<button type="button" onclick="goToYoutube()">GO</button>
</body>
I don't know if that link is correct, but the code works!

How to send data via HTML

Hi I need send actual time via html, like: /time_12:12_1.1.2018 on action on button or automatic. I have codes but I donĀ“t know how to connect it.
TIME:
<script>
document.getElementById("demo").innerHTML = Date();
</script>
Sending data:
<form action="/">PWM:
<input name="PWM" value="50" type="text"><input value="Submit" type="submit"></form>
Any ideas?
you want to submit the date as form data, or as part of the uri?
As form data
<form action='/' method='POST'>
<input type='hidden' id='time' value='' />
<input type='submit' value='Submit' />
</form>
<script type='text/javascript'>
document.getElementById('time').value = Date();
</script>
As URI
<form id='timeForm' action='' method='POST'>
<input type='submit' value='Submit' />
</form>
<script type='text/javascript'>
document.getElementById('timeForm').action = '/'+Date();
</script>

how put put dynamically populated number into input value field

I have dynamically populated value coming from an external js file. The value is working just fine when I call it in the HTML page but I'm stuck on how to have an input field display this value.
Here is my HTML:
<form action="../mail.php" method="POST" class="location-form">
<div class="device-details">
<h2>Device: iPhone5</h2>
<h2>Repair Cost: <span id="result">0</span></h2>
</div>
<input name="device" type="hidden" id="device" value="iPhone5" maxlength="20">
<input name="cost" type="hidden" id="cost" value="" maxlength="20">
<div class="submit-btn">
<input type="submit" value="Submit Request" />
</div>
</form>
<script>
document.getElementById("result").innerHTML = localStorage.getItem("sum");
</script>
at the top, in the div "device-details", the h2 "repair cost" is populating the value just fine, no issues. But I cannot seem to populate the last input with this value.
<input name="cost" type="hidden" id="cost" value="(need the value here)" maxlength="20">
I need the value of the input field to mimic the value of the repair cost at the top in order to send that value to an email address.
I've tried inserting the following into the value and it didn't work
value="<span id='result'>0</span>"
I've tried creating a variable in php and then putting the variable into the value field, and it did not work
<?php
$my_var = '<span id="result">0</span>';
?>
value="<?php echo '$my_var'); ?>"
I've also tried:
value="<?php echo htmlspecialchars($my_var); ?>"
these last two just returned the actual HTML code
<span id="result"></span>
instead of the populated value.
Try this one.
<!DOCTYPE html>
<html>
<body onload="abc()">
<form action="../mail.php" method="POST" class="location-form">
<div class="device-details">
<h2>Device: iPhone5</h2>
<h2>Repair Cost: <span id="result">0</span></h2>
</div>
<input name="device" type="hidden" id="device" value="iPhone5" maxlength="20">
<input name="cost" type="hidden" id="cost" value="" maxlength="20">
<div class="submit-btn">
<input type="submit" value="Submit Request" />
</div>
</form>
<script>
function abc(){
document.getElementById("result").innerHTML=localStorage.getItem("sum");
document.getElementById("cost").value = localStorage.getItem("sum");
}
</script>
</body>
</html>

html javascript type=file

With a html type=file, how can I validate to determine if a file was uploaded, (for client side validation using javascript or jquery)
<form action="program" enctype="multipart/form-data" method="post">
<input type="text" name="textline" size="30">
<input type="file" name="datafile">
<input type="submit" value="Send">
</form>
<script>
if (something )
message = "You did not upload a file...";
</script>
Same way as any other input, look at the value. For example
<form id="programform" action="program" enctype=...
<script type="text/javascript">
document.getElementById('programform').onsubmit= function() {
if (this.elements.textline.value==='')
alert('Please enter a description.');
if (this.elements.datafile.value==='')
alert('Please choose a file to upload.');
else
return true;
return false;
}
</script>
Thanks for the push in the right direction... Here is what I was looking for.
<form name="registration_2" id="registration_b" action="registration_b.php" method="post" nctype="multipart/form-data" accept-charset="UTF-8" onsubmit="return check_checkboxes();">
<input type="text" name="textline" id="textline" size="30">
<input type="file" name="datafile" id="school_logo_id">
<input name="no_school_logo_id" id="no_school_logo_id" type="checkbox" onclick="no_school_logo(this);"/>Our school does not have a logo
<input type="submit" value="Send">
</form>
<script type="text/javascript">
function check_checkboxes()
{
var logo = document.getElementById('school_logo_id');
var nologo = document.getElementById('no_school_logo_id');
if (logo.value==='' && nologo.checked===false)
alert('Must enter logo file or check no file available.');
}
</script>