LelloLello
asked on
How do you add a required field to your code - NOT a pop window,
How do you add a required field to your code - NOT a pop window,
The message should show above the question , Please complete required question 1.
For your information.
If the user didn't select yes or no, a msg should show saying.
1. Please complete question 1.... Where I can put that in my code?
here is the code:
<script type="text/javascript">
function checkme(ele){
var inputbox = document.getElementById("s pecify");
if(ele.value=="Yes"){
inputbox.style.display="bl ock";
var er = document.getElementById("e rror");
er.style.display="none";
}else{
inputbox.style.display="no ne";
}
}
function checksubmit(f){
var radio = f.contactMeYes.value;
var inputbox = f.ContactMeSpecify.value;
if(radio=="Yes" && inputbox==""){
var er = document.getElementById("e rror");
er.style.display="inline";
return false;
}else{
var er = document.getElementById("e rror");
er.style.display="none";
return true;
}
}
</script>
<cfform id="form1" name="form1" onSubmit="return checksubmit(this);" action="confirmation_e.cfm " method="POST">
Please complete this form<br><br>
<b>(*) Required field </b><br>
* <p><br><label for="strEmail"><strong><st rong>1.</s trong> If your skill set is suitable to other committees, would you be willing to be contacted regarding any openings? </label> </p>
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
<tr>
<td colspan="2" height="5" width="100%">
<input type="radio" name="contactMe" id="contactMeYes" value="Yes" onClick="checkme(this);"/> <lab el for="ContactMeYes">Yes</la bel>
<input type="radio" name="contactMe" id="contactMeNo" value="No" onClick="checkme(this);"/> No</label>
<br>
<div id="specify" style="display:none;">
<label>Please specify:
<input type="text" name="ContactMeSpecify" id="ContactMeSpecify" value="" maxlength="255" size="30" style="width: 200px;border:red 1px solid;">
</label>
</div>
</td></tr></table>
</cfform>
q1.jpg
q1ifYes-selected-textfield-wills.jpg
The message should show above the question , Please complete required question 1.
For your information.
If the user didn't select yes or no, a msg should show saying.
1. Please complete question 1.... Where I can put that in my code?
here is the code:
<script type="text/javascript">
function checkme(ele){
var inputbox = document.getElementById("s
if(ele.value=="Yes"){
inputbox.style.display="bl
var er = document.getElementById("e
er.style.display="none";
}else{
inputbox.style.display="no
}
}
function checksubmit(f){
var radio = f.contactMeYes.value;
var inputbox = f.ContactMeSpecify.value;
if(radio=="Yes" && inputbox==""){
var er = document.getElementById("e
er.style.display="inline";
return false;
}else{
var er = document.getElementById("e
er.style.display="none";
return true;
}
}
</script>
<cfform id="form1" name="form1" onSubmit="return checksubmit(this);" action="confirmation_e.cfm
Please complete this form<br><br>
<b>(*) Required field </b><br>
* <p><br><label for="strEmail"><strong><st
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
<tr>
<td colspan="2" height="5" width="100%">
<input type="radio" name="contactMe" id="contactMeYes" value="Yes" onClick="checkme(this);"/>
<input type="radio" name="contactMe" id="contactMeNo" value="No" onClick="checkme(this);"/>
<br>
<div id="specify" style="display:none;">
<label>Please specify:
<input type="text" name="ContactMeSpecify" id="ContactMeSpecify" value="" maxlength="255" size="30" style="width: 200px;border:red 1px solid;">
</label>
</div>
</td></tr></table>
</cfform>
q1.jpg
q1ifYes-selected-textfield-wills.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it's not displaying 'Required impute ! or else... ' or anything to force the user to fill question one why ?? here is the code for your review what i'm missing... Required input! Or else... click "No" above... </
<script type="text/javascript">
function checkme(ele){
var inputbox = document.getElementById("s
if(ele.value=="Yes"){
inputbox.style.display="bl
var er = document.getElementById("e
er.style.display="none";
}else{
inputbox.style.display="no
}
}
function checksubmit(f){
var radio = f.contactMeYes.value;
var inputbox = f.ContactMeSpecify.value;
if(radio =="")
{
var error = document.getElementById("I
error.style.display="inlin
return false;
}
else if(radio=="Yes" && inputbox==""){
var er = document.getElementById("e
er.style.display="inline";
return false;
}else{
var er = document.getElementById("e
er.style.display="none";
return true;
}
}
</script>
<cfform id="form1" name="form1" onSubmit="return checksubmit(this);" action="confirmation_e.cfm
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
<tr>
<td colspan="2" height="5" width="100%">
<input type="radio" name="contactMe" id="contactMeYes" value="Yes" onClick="checkme(this);" /> <label for="ContactMeYes">Yes</la
<input type="radio" name="contactMe" id="contactMeNo" value="No" onClick="checkme(this);" />No</label>
<br>
<div id="specify" style="display:none;">
<label>Please specify:
<input type="text" name="ContactMeSpecify" id="ContactMeSpecify" value="" maxlength="255" size="30" style="width: 200px;border:red 1px solid;">
</label>
<p id="error" style="color:red;display:n
</div>
</td>
</tr>
</table>
</cfform>
Open in new window