跳至內容
選單
此問題已被標幟
2 回覆
8525 瀏覽次數

   <script type="text/javascript">

function ddlValidate() {

var qq = document.forms['frm'].question.value

if(qq === "") {

alert("empty");

document.getElementById(question).style.background ='#F99984';

return false;

}

var e = document.getElementById("ddlView");

var optionSelIndex = e.options[e.selectedIndex].value;

var optionSelectedText = e.options[e.selectedIndex].text;

if (optionSelIndex == 0) {

alert("Please select a Course");

return false;

}

return true;

}

</script>

<template id="ibregistration">

<t t-call="website.layout">

<form action="/website/form/" method="post" class="form-signin s_website_form form-horizontal container-fluid mt32" enctype="multipart/form-data" data-model_name="ibprogram.studentregistration" data-success_page="/onetimepassword" >

<input name="question"/>

<span id="errorSpan" style="color: red;"></span>

<div>

<span>Select the course : </span>

<select id="ddlView" >

<option value="0">Select</option>

<option value="1">Java Script</option>

<option value="2">CSS</option>

<option value="3">JQuery</option>

<option value="3">HTML</option>

<option value="3">C#</option>

</select>

</div>

<input type="submit" class="btn" value="Submit" id="btnSubmit; insert" onclick="ddlValidate();" />

</form>

   </t>

</template>

頭像
捨棄
作者

how to stop my form getting submitted

Why don't you just add required="required" to your select? Don't know for select but for input it works. Have you tried it?

最佳答案

make input type="button"
<input type="button"........ />

頭像
捨棄
作者

document.getElementById("frm").submit();

i mentioned the above code in javascript and created <input type="button"........ />

now form not submitting

作者

what to do ??

作者

<form name="frm" id="frm" action="/website_form/" method="post" class="s_website_form form-horizontal container-fluid mt32" enctype="multipart/form-data" data-model_name="ibprogram.studentregistration" data-success_page="/christjobs/thankyou" >

why you need js to submit? what is your actual need? you should keep the standard of asking questions, the question should be better formatted.

作者

i have a registration form, form should get submit after performing validation

here validation is performing but form is not submitting

my form is like this.

======================form====================

<form action="/website_form/" method="post" class="s_website_form form-horizontal container-fluid mt32" enctype="multipart/form-data" data-model_name="empdetails.regis" data-success_page="/christjobs/thankyou" >

<input type="text" name="reg_name" class="form-control" placeholder="NAME OF STUDENT AS PER 10 RECORD " />

<input type="button" class="btn" value="Submit" id="btnSubmit; insert" onclick="ddlValidate();" />

</form>

=================java script=====================

function ddlValidate() {

var reg_name = document.forms['frm'].reg_name.value

if(reg_name === "") {

alert("reg_name empty");

document.getElementById(question).style.background ='#F99984';

return false;

}

if(reg_name != ""){

document.forms["frm"].submit();

}

return true;

}

相關帖文 回覆 瀏覽次數 活動
3
7月 20
8158
1
10月 17
7541
1
7月 17
7883
0
10月 22
2175
2
1月 18
2768