Validating A Form With Options
Jan 12, 2008
I am helping someone out with a form. He wants the name required, easy enough, but then only an email or street address required. I have tried a couple of things and it is not working.
I am trying a very simple code:
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if ( document.contact_form.name_mailing.value == "" )
{
alert ( "Please fill in the 'Your Name' box." );
valid = false;
}
if ( document.contact_form.address_mailing.value == "" || document.contact_form.email_address.value == "")
{
alert ( "Please fill in the 'Your Information' box." );
valid = false;
}
return valid;
}
//-->
</script>
Am I not using the or operator correctly? I only want to have the address or email required, not necessarily both.
View 2 Replies
ADVERTISEMENT
Mar 21, 2010
I am using a validating form plug in for jquery and I have a question about it. Let this function will be an ex.:
[Code]....
'e' is the name attribute of one form element, but can I choose more elements using jquery (CSS) rules like this: input[name*=e] or how can I do something similar?
View 5 Replies
View Related
Dec 3, 2006
How can I combine these 2 functions?
function POvalidator()
{
var obj = document.Form1;
if (obj.PONumber.value == "") {
alert("Please enter a value for the PO Number field.");
obj.PONumber.focus();
return false;
}}
function checkCheckBox(){
if (f.agree.checked == false )
{
alert("Tou must agree to the Terms to continue");
return false;
}else
return true;
}
View 6 Replies
View Related
Jan 30, 2011
I have a form that is passed to itself. I was just wondering if there was a way to get this to validate before it passed to itself.I was assuming that as the form doesn't properly submit, I could not use onsubmit="return sValidation()", so I have it on the buttons onclick. Correct assumption or not? Is there a way round this at all and to get it to validate?
<form action="" method="post" name="searchform" >
<table width="200" border="0" cellpadding="2" cellspacing="0" class="adforms">
<tr>
[code]....
View 4 Replies
View Related
Aug 31, 2010
Why my email field is validating, but mycode for validating empty fields is not?
View 1 Replies
View Related
Jun 30, 2009
For some reason my form isn't validating. I manage to get the "Please select an option" alert, but it still posts the form.
2 sizes available
<SCRIPT language=javascript>
function CalculateOrder(form){
if (form.os0.value == "8x10"){
form.amount.value = "90.00";
form.shipping.value = "15.00";
}.....
View 2 Replies
View Related
Apr 5, 2011
Here's what I have so far in my validation part However, I need help as to how to validate the following fields when the user clicks the submit button.
-Radio Button
*title (4 options)
*member (3 options)
*vegetarian (2 options)
[Code]...
View 3 Replies
View Related
Jul 20, 2005
I have a form with a few text boxes which need to be validated client-side.
The validation is: check that every single text box has a unique string value.
I.e., I need to check that there are no two textboxes that both contain,
for example, the string 'hello'.
Is there an efficient way to do this kind of validation in javascript?
View 2 Replies
View Related
Jul 15, 2009
I am using the Jquery validationss plugin for my form validations. NowI have a situation where I have two submit buttons in a single form(say button A and button B). For button A, I want to run validationsbut for button B I don't want to run the validations and submit theform without validating.. How can i do this?
View 2 Replies
View Related
Nov 27, 2002
This script allows you to replay the event-controls coded on your INPUT tags.
You must have a <div id="msgErreur"></div> in your HTML page.
PS : I'm working for an Intranet Webapp. All the users are on IE6.
So i don't mind with NS compatibility
-----------------
// Wait the end of load before manipulating elements
window.onload=doLoad;
function doLoad() {
if (document.forms.length > 0) {
for(i=0;i<document.forms.length;i++) { document.forms[i].onsubmit=doSubmit; }
}
}
function doSubmit() {
if (document.all["msgErreur"]!=null) {
if (document.forms.length > 0) {
message=document.all.msgErreur.innerText;
message=''
for(i=0;i<document.forms.length;i++) {
for(j=0;j<window.document.forms[i].elements.length;j++) {
cible=window.document.forms[i].elements[j];
if (target.value!='') {
cible.fireEvent("onchange");
cible.fireEvent("onfocus");
cible.fireEvent("onblur");
if (message!='') {return false;}
}
}
}
}
}
}
View 3 Replies
View Related
Dec 10, 2007
I have a group 2 Radio buttons, if the user selects the 2nd Radio button then they need to enter some data into a text field... The following only works for either Radio buttons... How can I specify it to be only the 2nd Radio button?
if(!document.form.radio1.checked && document.form.q3.value=="")
{
theMessage = theMessage + "
--> You selected no we need a reason)";
}
View 5 Replies
View Related
Mar 3, 2011
This is my form
<form name="myForm1" onsubmit="return validateForm(myForm1)" method="post" action="add.php?pif=ixhsuwu9xyysysjj300&yisu=uuwuwuwzuab&jsn=733888559jdjdjdeyey&tsyi=378hyxbh738hssh272sh&zy9stxyw=idÂ272bs2637shuw727hhshs377ywwwyw&nav=events">
<table width="100%" border="0" cellspacing="3" cellpadding="0" bgcolor="ffffff">
<tr>
<td colspan="4" bgcolor="#FF9933" class="fonts"><img src="/img/spacer.gif" width="1" height="1"></td>
</tr><tr>
<td colspan="4" class="fonts" align="center"> Pls. Note : All fields must be completed in order to proceed.</td>
</tr><tr>
<td width="23%" nowrap class="fonts" bgcolor=#EEF8C6><div align="right">Job Title <strong>:</strong> </div></td>
<td width="77%" valign="middle" bgcolor=#EEF8C6 class="fonts"><input type=text name=jobtitle class='bodytext' size="60"> .....
View 3 Replies
View Related
Feb 18, 2010
I am using the following simple script for validatingmy form:
Code:
When the page is rendered I keep getting a 'Syntax Error'..and it is specific to the validation...but I do not know why. When i remove one of the textboxes from the validation script it works.
View 3 Replies
View Related
Aug 24, 2010
I have made working validation of form:URL...And then I've tried to make the same validation but in form witch radios. And my problem is that it isn't working at all.
View 11 Replies
View Related
Feb 17, 2009
I have some checkboxes in a form that I'd like to validate (check to ensure that at least one has been ticked):
HTML Code:
<input type="checkbox" name="response[]" value="answer1" />answer1
<input type="checkbox" name="response[]" value="answer2" />answer2
<input type="checkbox" name="response[]" value="answer3" />answer3
<input type="checkbox" name="response[]" value="answer4" />answer4
The javascript below only works if I change my checkbox names to name="response" rather than name="response[]".
Code:
function validateform(){
var success = false;
for (i = 0; i < document.surveyform.response.length; i++){
if (document.surveyform.response[i].checked){
success = true;
}} return success;
}
I need to pass along multiple checkbox responses to my PHP script and therefore need to keep checkboxes named name="response[]". When I do this, I get the error "document.surveyform.response has no properties"
What change I can make to the javascript so that I can name my checkboxes name="responses[]" ?
View 2 Replies
View Related
Jul 24, 2010
I'm a student learning web design and having a problem with some javascript code, I'm validating a text area, i dont have a problem limiting how many characters can be typed in the textarea, but I cant get it to give an error if there is no text in the text area. In the code below the validateMes() function is not working, the other functions work fine
[Code]...
View 4 Replies
View Related
Oct 22, 2011
I am having problem in validating my form using spry tools. The problem is that if I try to include any other validation other than spry along with spry validation the spry validation does not work.
View 1 Replies
View Related
Sep 10, 2009
I have the form:
<form>
<div id="portion1">
... some inputs ...
</div>
[code]....
By default, only #portion1 is visible. If inputs inside it are all valid, #portion2 will be visible and #portion1 will be hidden, and so
on. The problem is that jQuery Validate will only validate the whole form, so something like $('#portion1').validate().form() won't work.
View 2 Replies
View Related
Dec 8, 2009
I am somewhat a noob at js/jquery so I wasn't sure exactly how to do this. Think I just need a push in the right direction. Basically I'm trying to validate a form (jquery validation) with a couple of conditionals based on a selection box. So I have:
<form id="info" class="validate">
<select id="select">
<option value="senior">Senior Citizen</option>
[code]...
I'm trying to validate that if the user has selected "Senior Citizen" then their age must be 65 or older (and validate the adult/child ages as well).
View 6 Replies
View Related
Nov 1, 2011
validating the password strength of my form. I am actually looking for a regular expression that could force the users to have at least 2 of the following:
1. Upper and lower case.
2. Numbers
3. Symbols.
View 6 Replies
View Related
Apr 8, 2010
I'm not sure how to do this because I added a js function to run on a form's submit button's click event. The js function does run, but then no matter what, the php script is called. The alert runs, then it goes to the php script. How can I stop it doing it?
here is js function:
Code JavaScript:
function checkFields(form){
var myForm= document.getElementById(form)
if(myForm!="li-comment-form"){
[Code]....
View 7 Replies
View Related
Apr 8, 2010
how to do this because I added a js function to run on a form's submit button's click event. The js function does run, but then no matter what, the php script is called. The alert runs, then it goes to the php script. How can I stop it doing it? here is js function:
[Code]....
View 2 Replies
View Related
May 11, 2009
I am validating my form fields using jquery validate plugin. but itsnot executing my methods. its hitting my validate() method but notactual validation code.I am pasting my code here for your reference.My javascript code:
mysite.validateFormFields = function() {
alert('here'); [color=green] [b]// its hitting here
[/b][/color]
[code]....
View 3 Replies
View Related
Dec 2, 2004
I have a form that makes visible a text field when a specific radio button is checked. That works. Then I validate to see if a radio button is checked before I let the form be submitted. That works.
BUT - I cannot seem to get it to validate the form field that is made visible to see if it has content or at least the proper content when the form is submitted. Can you tell me what I am doing wrong please?
I can give more info on what kind of validation I want done if needed, but I think my code speaks for itself Code:
View 4 Replies
View Related
Dec 3, 2005
I want to validate an HTML form, that have array filed names. For example
<INPUT TYPE="TEXT" NAME="contact[name]">
<INPUT TYPE="TEXT" NAME="contact[email]">
I need this as a program require contact us form in this format (sunshop).
if(document.formname.contact[name].value.length==0) { alert('You must enter name'); return false; } But not working. Code:
View 1 Replies
View Related
Mar 5, 2006
I am trying to throw in some client-side validation to my php web form. My problem is that only one field is actually getting validated. Here is the code:
Form: onSubmit="return checkForm(this);"
script: function checkForm(form) {
var firstname = document.getElementById("wpFirstName").value;
var lastname = document.getElementById("wpLastName").value;
if (firstname == "") {
document.getElementById("firstNameError").style.display="inline";
document.getElementById("wpFirstName").select();
document.getElementById("wpFirstName").focus();
return false;
}else if (lastname == "") {
document.getElementById("lastNameError").style.display="inline";
document.getElementById("wpLastName").select();
document.getElementById("wpLastName").focus();
return false;
}
return true;
}
The if statement evaluating the last name field is the only statement that evaluates to true. It seems the first statment is bypassed. Any ideas? PS. the element with the id lastNameError/firstNameError is in a div tag.
View 4 Replies
View Related