تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
8524 أدوات العرض

   <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
يوليو 20
8156
1
أكتوبر 17
7538
1
يوليو 17
7882
0
أكتوبر 22
2175
2
يناير 18
2767