Auto update blank value in form by using other field value and default value

Hello Mate I need your help.

I have a form with 2 field
#WA-Number
#Email

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 :smiley: i hope u get what i mean…


Here is my site Read-Only:
https://preview.webflow.com/preview/sgala-com?utm_medium=preview_link&utm_source=designer&utm_content=sgala-com&preview=ebfd1e7c73d7c4b545ff738c663e9ee7&pageId=5e981c21430c975f36a59f9d&itemId=5e9821c3d8267b070276ae3e&mode=preview

Hi @Adhi_Wiratama,

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
  }
});

If this doesnt work, you may need to look into using custom submit function from here: Customizing Form Submit Action

Thx for ur help mate, ill try this one, and going back here about the result…

BTW r u from indonesia? Your name sound like someone from indonesia, maybe i can use ur service later in the future… :smiley:

Yes mas, email saya denny@density.digital kalau ada keperluan Webflow :slight_smile:.

Coba dulu code yang tadi, kalau ga bisa reply disini aja saya coba bantuin.

Let’s not using bahasa, so this page will also usefull for others.

I’ve tried the code but the result still blank on the submission form…
Maybe another solution mate?

Out of topic :
Can u help me on this, pls check

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
  }
});

Still nothing happen…

I have several script on the page, pls help tp check maybe some of it cause the problem…

Thx for ur time

Hi @Adhi_Wiratama, can I have the published link so that I can try to troubleshoot there?

I can’t really test the code on webflow preview.

https://www.s-gala.com/admin-s-gala/fanya

pls check

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.
    }
});

i have try the solution… the massage is pop up when no email is detected… Now the problem is the data is not going to the submission form…

:smiley:

I see you have script to send the input to Whatsapp. You can combine the 2 chunks of codes together and use the email variable to send to whatsapp.

If you want email to appear on the input field you can add document.getElementById('Email').value = email

What i mean the submission form is the submission data on webflow form… The data is not there after i submit…