Require One Of Two Fields To Be Filled (either/or)?
Sep 22, 2010
Here is my issue that I am trying to resolve. I know how to make a field in a form required for validation however what I am trying to do is require that at least one of two available fields is filled in. The form performs a search using the 'first name', 'last name' or both. What I need is for the form to require at a minimum that at least one of the two fields is filled in prior to sending it to the script to do the search.Here is what it should do in each instance:
[first name] [NA] = form submitted
[NA] [last name] = form submitted
[first name] [last name] = form submitted
[na] [na] = Not submitted
I have a form that has 9 pairs of fields on it. I'd like to change this so that there are only two blank pairs of fields displayed. As the user fills out a pair of fields, it adds another pair of blank fields. This way, the user can fill out as many as their heart desires, but those who don't have that much information to provide, aren't confronted with an unnecessarily huge form of blank fields.
I'm running two different forms on one page.Each form goes to a different place - one form does stuff on a different server and one form does stuff on the same server.This is being accomplished by using the following script (found here on WebDeveloper)
HTML Code:
<script language='javascript'> <!-- function doit()
<form id='form2' name="form2" method="POST" action="attachscript.php" enctype="multipart/form-data" target='_blank'> There is no submit function in the forms.
After the two forms are listed, there's one link that processes both forms at the same time when clicked:
HTML Code:
<div align="center"><a href='javascript:doit()'>Click Here To Submit</a></div>
Here's the good news: THIS WORKS. This is not the problem.The problem is my client wants most/all of the content in form2 to be filled out. If the fields are not filled out, then something happened that says in effect "yo. fill that out!"I've tried to use javascript validation scripts and they don't work. Presumably because they depend upon
I'm facing a validation error, whenever I leave any of the fields blank, it gives me a warning and then it redirects me to (index.php?option=com_ccnewsletter&view=ccnewsletter)What I wanna know is how can I freeze the page until all fields are filled?This is the javascript code:
<script type="text/javascript"> function formsubmit(task) {[code]....
How do I disable the submit button if all required fields in a form are not filled in? Say I have a form with Name, Age,message, and email. Name, message and email must be filled in or else the submit button will not show or will be disabled and then enabled once filled. If the fields are filled in then the submit button will show. If the fields are filled in but then one is deleted then the submit button will hide. Ideally if I can have it disabled that will work, if not I will settle on hide at this point.
For example, I'm using it now to put different ads on different forum pages after checking the forum number in the URL. If there's no match, I don't want an ad on the page.
Is my code above "legal" or does it require an else at the end?
BTW, the reason I do it that way instead of just using ifs is that I figured that once it found a true condition it wouldn't bother reading the following else ifs and that would save time... it would run faster.
I am using javascript to verify a text input box but I would also like to require atleast 3 characters being entered before allowing the user to search.
I'm playing with a greasemonkey script and would like to provide geo-locating. The geolocation services I've found all require dev/api-key. A dev-key means I reveal my well-earned key, or an api-key usually means a server address... there would be none via a greasemonkey script.
So I understand you can do: $(".className").xxx. Is there an easy way with jquery to have it match 2 classes. So maybe I only want the action to take place it the element has class1 and class2. $(".class1" , ".class2").xxx The above is close to what I would like, but thats if any of the 2 classes match, go. I need it to be both. I can probably do this with some basic javascript logic.. just figure there may be a function for this already.
As you can see below in example #1I am attempting to assign a variable value to the 'URL:' key. I am having problems with this Ajax call but I don't know if this is the cause. I even tried using eval() in example #2 below. I am pretty new at this stuff so forgive my ignorance.
Does the 'url::' key REQUIRE a literal string?? Is there no way to set this value at run time?
I'm trying to set up a form that has a text field that is required to be blank - I'm dealing with form spam, and the bots are stuffing every text field with random crap. So, I have a text box that is required to be blank. But I can't get jquery.validate to understand both required and blank.the text input is has a name and id of live_check.I have added this method:
$.validator.addMethod("equalToParam", function(value, element, param) {return value == param;});
I want to add a simple alternative to CAPTCHA on a form by adding a required text input - e.g.Type the word "jquery":How do I add a rule requiring a specific value?
I have an issue with a registration form. What I would like to do is only allow a certain email domain in the 'email' field. Eg. Only allowing @gmail.com email addresses, and all others would receive an error. This is the line of code that I believe needs changing:
function isEmail(valor){if(/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,4})+$/.test(valor)){return(true)}else{return false;}}
I am not too familiar with this but through my hours of research, I believe that I need to add something to this line.
I am trying trying to create a site that will require a database. (much like facebook functions)
I am not new to programming, as I know Java and C++, but I am very new to the web development.
For security reasons (so I have heard), I would like to write this site in php. At the same time, I may need some client sided code. (Or do I?) I am not at all sure.
I know that facebook is written in php, and the site I am making basically has the majority of those functions.
Any inputs as to how I should go about choosing what language? As of now, my partner is learning javascript and mysql, while I am studying php and mysql.
I know that some sites implement both, javascript and php, but I was wondering if it is at all necessary to use both, and how would one know which code to write in what language.
I have a working example of jQuery validate working in the link below. The newsletter checkbox is required and working. However, the "colors" checkboxes are all named as an array ( ex: name="color[]" ), and so the problem lies in the validation code, where it uses the name of the element to require elements ( ex: newsletter: "required" ).
Info:- jquery-1.3.2- jquery.validate-1.5.5- form with 1 dropdown select and 4 text inputsSetup:- all 4 text fields are not initially required.Issue:The first input element is a required dropdown select.If the user selects option 1, then text field 1 & 2 need to be required.If the user selects option 2, then text field 3 & 4 need to berequired.How do code this?