是否可以通过调用来触发表单的 onSubmit 事件
function submitEdit(){
document.getElementById("edit").submit();
};
Run Code Online (Sandbox Code Playgroud)
这种方法行不通
形式:
echo "<form id='edit' onsubmit='validate(flag, typeFlag)' method='post' style='width: 100%;height:86%;'>";`
Run Code Online (Sandbox Code Playgroud)
onSubmit 事件:
window.flag=false;
var typeFlag;
function validate(flag, typeFlag) {
if ( (flag==true) && (typeFlag==true) ){
document.getElementById("edit").setAttribute('target', '_self');
document.getElementById("edit").action ="date.php";
} else if ( (flag==true) && (typeFlag==false) ){
document.getElementById("edit").setAttribute('target', '_blank');
document.getElementById("edit").action ="date_PDF.php";
} else
alert("Select an aircraft");
}
Run Code Online (Sandbox Code Playgroud)
我做对了吗?我需要通过单击单选按钮来提交此表单。
echo '<td class="c3" style="color: #f79393">
<div class="radio">
<label><input type="radio" name="name_check" onclick="typeFlag=true; submitEdit();" class="c3" value="in" id="c3" '; if($flag) echo'checked'; echo '>in</label>
</div>
</td>';
Run Code Online (Sandbox Code Playgroud)
谢谢你!
我使用有角度的材料,并且有一个带有反应验证的表单。
\n\n我想在提交后重置我的表单,我的问题是提交后我看到我的错误出现在表单中。
\n\n输入示例:
\n\n<mat-form-field>\n <mat-label>Pr\xc3\xa9nom</mat-label>\n <input matInput name="prenom" formControlName="prenom">\n <mat-error *ngIf="f.prenom.hasError(\'required\') && submitted">\n Ce champ est obligatoire\n </mat-error>\n <mat-error *ngIf="f.prenom.errors?.maxlength && !f.prenom.hasError(\'required\')">\n le pr\xc3\xa9nom ne peut pas d\xc3\xa9passer 20 caract\xc3\xa8res\n </mat-error>\n</mat-form-field>\nRun Code Online (Sandbox Code Playgroud)\n\n我尝试添加提交的变量和 this.myForm.markAsUntouched() 但不起作用
\n\nonSubmit() {\n this.submitted = true;\n if (this.myForm.invalid) {\n return;\n }\n alert(\'Form Submitted succesfully!!!\\n Check the values in browser console.\');\n console.table(this.myForm.value);\n this.submitted = false;\n this.myForm.reset();\n this.myForm.markAsUntouched();\n}\nRun Code Online (Sandbox Code Playgroud)\n\n使用提交的变量,我看到消息错误消失(下面的黄色部分),但边框和红色没有消失。
\n\n\n\n你们有什么想法来解决这个问题吗?
\n我创建了一个新的免费 Slack 工作区来学习 Slack 机器人应用程序 API。我有一个动作处理程序,它监听全局快捷方式并打开一个输入模式作为响应。还有另一个操作处理程序,它侦听模态输入 Submit callback_id,执行一些工作,然后使用trigger_id打开另一个模态。
app.view('do_thing_b.submit', async (slack) => {
try {
await slack.ack()
console.info(`Received modal submit`)
// TODO: actual work to save the data
const view = {
type: 'modal',
callback_id: 'do_thing_b.received_submission',
title: {
text: 'Thing B Done',
type: 'plain_text',
},
blocks: [
{
type: 'section',
text: {
text: 'My Plain Text',
type: 'plain_text',
emoji: true,
},
},
],
close: {
text: 'Close',
type: 'plain_text'
}
}
const openViewParams = {
trigger_id: slack.body.trigger_id, …Run Code Online (Sandbox Code Playgroud) 由于jquery,由于某些奇怪的原因,我收到错误"对象预期",并且这不会"提交"表单或将数据输入数据库.
没有jquery,数据可以输入数据库.但现在却没有.
我使用jquery主要用于验证asp.net控件.
roosteronacid,验证工作完全正常,id属性也相同.提交只是没有执行服务器端代码,我无法弄清楚是什么问题.
编辑:
这是jquery代码:
<script type="text/javascript">
$(document).ready(function() {
// add custom validation methods
$.validator.addMethod('phone', function(value, el, params) {
return this.optional(el) || /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/.test(value);
}, 'Please enter a valid phone number');
$.validator.addMethod('numbers', function(value, el, params) {
return this.optional(el) || /^[0-9]+$/.test(value);
}, 'Invalid entry. Only Numeric is allowed.');
$.validator.addMethod('domainurl', function(value, el, params) {
return this.optional(el) || /^(http\:\/\/(?:www\.)?[a-zA-Z0-9]+(?:(?:\-|_)[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:(?:\-|_)[a-zA-Z0-9]+)*)*\.[a-zA-Z]{2,4}(?:\/)?)$/.test(value);
}, 'Please enter a valid domain url');
$.validator.addMethod('selectone', function(value, element) {
return this.optional(element) || (value.indexOf("none") == -1);
}, 'Please select an option.');
$("#form1").validate({ …Run Code Online (Sandbox Code Playgroud) $('#search_form').submit(function(e) {
//e.preventDefault();
return false;
})
Run Code Online (Sandbox Code Playgroud)
按Enter键可以防止表单提交.
但是即使我有这个,我想在某些情况确实的情况下用jquery提交表单.
编辑:
$('#search_form').submit(function(e) {
return !!e.submit;
});
function ...
if (e.keyCode == 13) {
if (blablabla) {
... // do something
} else {
$('#search_form').submit({submit:true}); //doesn't work
console.log('submitted'); //this does successfully get fired
}
}
Run Code Online (Sandbox Code Playgroud)
如果我按回车键表单没有提交,但是在控制台中登录就会发生!
当用户使用jQuery单击选项时,如何提交表单?我使用datepicker文本输入找到了一个类似的问题,但我不熟悉jQuery,所以我似乎无法将其转换为选择项目.
我正在为我的表单寻找一个自动提交功能,一旦用户输入一定长度的文本(比如15个字符)到输入字段,它就应该提交.
在jQuery中是否有任何函数(在非常短的时间间隔内)检查输入字段中文本的长度,并在满足所需数量的字符后运行函数?有任何想法吗?
编辑:我正在寻找这个功能:用户进入页面的形式 - 输入字段上的autofocuses - 用户使用扫描仪读取条形码 - 然后条形码编号粘贴在输入字段(不是键盘,keydown事件)和表单是自动提交的.
求助:使用此函数来捕获输入字段中的更改:
$(#inputField).bind('input propertychange', function(){
dostuff();
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个JavaScript,它将自动按第三方网站上的“提交”按钮。基本上,如果我想使用包含用户名和密码的Cookie自动登录到站点(例如Google帐户),则javascript将自动按“提交”按钮,而无需我这样做。
我现在有这个.
//other stuff up here - not important
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='1' /><input type='hidden' name='id' value='" . $id . "' /><input type='submit' name='Redeem' value='Redeem'></form></td>";
} else {
echo "<td><form action='redeem.php' method='post' id='form'><input type='hidden' name='redeem' value='0' /><input type='hidden' name='id' value='" . $id . "' /><input type='submit' name='Un-Redeem' value='Un-Redeem'></form></td>";
//other stuff down here - not important
Run Code Online (Sandbox Code Playgroud)
我想改变它,以便当您按下:
a)"兑换"提交按钮时,它会提醒您说:"您确定要兑换吗?"
b)"Un-Redeem"SUBMIT按钮,它会提醒您:"您确定要取消兑换吗?"
我已经尝试了其中一些,包括提交上的ONCLICK,但没有一个工作..我相信这是因为我在ECHO中有它,我不得不删除阻止该功能发生的(")引号.
有人知道我能做到的另一种方式吗?
我现在提交:
method: save
name: Michael
birthday: 1983-02-01
Run Code Online (Sandbox Code Playgroud)
但是我需要:
method: save
data[name]: Michael
data[birthday]: 1983-02-01
Run Code Online (Sandbox Code Playgroud)
和字段名称必须像"生日"而不是"数据[生日]"
submit ×10
forms ×4
javascript ×4
jquery ×4
php ×2
validation ×2
account ×1
alert ×1
autologin ×1
database ×1
extjs ×1
form-submit ×1
html ×1
modal-dialog ×1
object ×1
onsubmit ×1
select ×1
slack-api ×1
view ×1