英文:
setting up an contact form to automatically send an email with formsubmit.co not working
问题
这是您提供的代码的翻译部分:
<h2 class="title">联系我!</h2>
<br>
<br>
<form (ngSubmit)="submitForm()" #contactForm="ngForm" action="https://formsubmit.co/katie.m.tantillo@gmail.com" method="POST">
<div class="field">
<label class="label">姓名</label><br>
<input
type="text"
size="maxlength"
name="name"
class="input"
[(ngModel)]="name"
#nameInput="ngModel"
required>
<div class="help is-error" *ngIf="nameInput.invalid && nameInput.touched">
<h6>请填写您的姓名。</h6>
</div>
</div>
<div class="field">
<label class="label">电子邮件</label><br>
<input
type="email"
name="email"
class="input"
[(ngModel)]="email"
#emailInput="ngModel"
required
email>
<div class="help is-required" *ngif="emailInput.invalid && emailInput.touched">
<h6>请填写有效的电子邮件地址。</h6>
</div>
</div>
<div class="field">
<label class="label">您的消息</label><br>
<textarea rows="2" cols="25" name="message" name="name" class="textarea" [(ngModel)]="message"></textarea>
</div>
<button
type="submit"
class="button"
[disabled]="contactForm.invalid">
<span>发送</span>
</button>
</form>
这段代码是一个包含联系表单的HTML代码。如果您有其他问题或需要进一步的帮助,请随时提问。
英文:
trying to set up a contact me with formsubmit.co but it doesnt seem to be working. heres the code for my form
` <h2 class="title">Contact Me!</h2>;
<br>
<br>
<form (ngSubmit)="submitForm()" #contactForm="ngForm"
action="https://formsubmit.co/katie.m.tantillo@gmail.com" method="POST">
<div class="field">
<label class="label">Name</label><br>
<input
type="text"
size="maxlength"
name="name"
class="input"
[(ngModel)]="name"
#nameInput="ngModel"
required>
<div class="help is-error" *ngIf="nameInput.invalid && nameInput.touched">
<h6>Please enter your name.</h6>
</div>
</div>
<div class="field">
<label class="label">Email</label><br>
<input
type="email"
name="email"
class="input"
[(ngModel)]="email"
#emailInput="ngModel"
required
email>
<div class="help is-required" *ngif="emailInput.invalid && emailInput.touched">
<h6>Please enter a valid email.</h6>
</div>
</div>
<div class="field">
<label class="label">Your Message</label><br>
<textarea rows="2" cols="25" name="message" name="name" class="textarea"
[(ngModel)]="message"></textarea>
</div>
<button
type="submit"
class="button"
[disabled]="contactForm.invalid">
<span>Send</span>
</button>`
I tried adding a tool to let me have an email automatically send from my website, I was expecting an email to be sent.
edited to add: this is the live site in question https://tantilloportfolio.web.app/
edited to add
export class ContactComponent {
name: string="";
email: string="";
message: string=""
submitForm() {
const message = `Thanks ${this.name}! Your message has been sent to katie.m.tantillo@gmail.com. Look for a reply to ${this.email} within 24 hours.`;
alert(message);
}
}
enter code here
答案1
得分: 0
action 和 ngSubmit 不能一起使用。这是你的问题。
请将你的表单标签还原为文档中所示。
如果你想要弹出窗口,将你的 submitForm 调用移至:
<button
(click)="submitForm()"
type="submit"
class="button"
[disabled]="contactForm.invalid">
<span>发送</span>
</button>
英文:
action and ngSubmit cannot be used together. This is your issue.
Revert your form tag to be as shown in the documentation.
If you wish to have a pop up, move your submitForm call to:
<button
(click)="submitForm()"
type="submit"
class="button"
[disabled]="contactForm.invalid">
<span>Send</span>
</button>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论