Since many of local people here dont have email, some of them will leave the #Email field with blank answer.
The case =
I want to auto fill the #Email field with “#WA-Number@noemail.com” when the answer is blank. #WA-Number was taken from the value of #WA-Number field and “@noemail.com” was a default text i want to use.
So when they click the submit button while the #Email value is blank, the value which is send to form submissions will automaticly change to the value i desire.
Example #WA-Number = 62811233333 #Email = blank
when people click sumbit button , 62811233333@noemail.com is used as the value for #Email
So there will be no blank value in my subbmission form result.
I use this for send the costumer data to SendInBlue, since they use email as a special ID for each data.
Thx for your help
Sorry for my bad english i hope u get what i mean…
You need custom code for that. Here’s roughly how it’ll look like:
// Get the values for both input
var wanumber = document.getElementById('WA-Number').value;
var email = document.getElementById('Email ').value;
$('.submit').on('click', function(){
// Create the placeholder email
var placeholder = wanumber + '@noemail.com'
// Check if email is present, if not set email to be placeholder
if (!email) {
email = placeholder
}
});
I changed .submit to #submit please give it a try.
var wanumber = document.getElementById('WA-Number').value;
var email = document.getElementById('Email ').value;
$('#submit').on('click', function(){
// Create the placeholder email
var placeholder = wanumber + '@noemail.com'
// You can remove this later
console.log(placeholder)
// Check if email is present, if not set email to be placeholder
if (!email) {
email = placeholder
}
});
Hi @Adhi_Wiratama, there was an extra space on Email so code below should work.
var wanumber = document.getElementById('WA-Number').value;
var email = document.getElementById('Email').value;
$('#submit').on('click', function(){
var placeholder = wanumber + '@noemail.com'
if (!email) {
email = placeholder
alert(email) // Just remove this after testing.
}
});