I have a selection list that users can choose one value from about 300 different values. I wish to add some cross value vaidations to ensure some extra data gets entered should the user choose one of 50 of these values. Now I know I can write a JS validation individully fo each of the 50 as follows:
if theForm.field1.value=="25" && theorm.field2.value =="" {
alert("Enter field2 value");
}
Then repeat this alidation 50 times.
My question - is there a way to shorten the code to someting like this:
var fieldx = "1, 2, 3, 4, 5"; etc with all 50 values defined here, then something like:
if theForm.field1.value==fieldx && theForm.field2.value =="" {
alert("Enter field2 value");
}
I am new to JavaScript and would really appreciate any help to solve my problem.
I am using the blow code in my form to validate form fields. What I would like to accomplish is that if when the list/menu (attribute6) value is "Ja" then to make the TextField Pas Nr (attribute4) required. And if when the list/menu (attribute6) value is "Nee" to make the TextField Pas Nr (attribute4) not required.
I have tried to adjust the code with no success. I give up and hope that someone can help me to the right direction! ....
I am validating a page (image attached) to make sure that total hours entered do not exceed the allocated amount, which is stored in the database. I have already validated to make sure that they enter a number and that it is not greater than 8.
var returncode = true var inputs = document.getElementsByTagName("INPUT") for(var x=0; x<inputs.length; x++) {
I want to check that only letters were entered in a field.formElements[i].value.search(/^[^a-zA-Z]+$/) != -1Will the above line be true if characters other than letters are found?
I am stuck on this seemingly simple validation loop.I want to iterate through a list of comma separated emails entered in a textarea input and check their validity before submitting the form.For some reason even when I enter all valid emails every other email doesn't pass the validation test!
var okEmailArr = badEmailArr = new Array(); var emails = $('#emailList').val(); // Get email list from text are input[code]....
I am looking for a little help validating a forms input. On the form are key items which I do not wish to be zero length.
I have wrote the following function:
<script language=javascript> function ValidateLength(oid, min, max) { var txt = document.getElementById(oid); var length = txt.value.length; if(length == 0) { alert("You must enter your reference, Company Name and Contact Name"); } } </script>
However their are still a few issues I would like to work out.
I all it with my forms sumbit event with the following:
However that will only check the length of the item txtRef, how can I check more textbox values? Also how can I stop the form posting if the alert is raised?
I'm working on a site where the name attribute of an input will not be known beforehand. I'd like to be able to modify or extend the validate plugin to set the rules and messages based off of the id of an input instead of using the name.
I've started a course on web design and I'm busy with a assignment on Javascript. I need to make a contact list which I'm nearly done with but I'm stuck with one bit, validating select lists, I want to do it using a case construct but I'm not sure how cause mine doesn't want to work.
I'm working on a page that has an iframe that loads a page with a file input on it. What I need to do is validate that file input to make sure that it isn't empty.
I am having 2 input fields. Both will have only the integer values. Its a minimum and maximum values. The condition is The minimum value of the 2nd input field should be greater than 1st input field. and 1st input field value should be minimum than 2nd input field. For that I tried with
The simplified code below works, and should give you an idea of what Im trying to achieve. The final version will have dozens of input fields so you can see why the below method stinks :D
<html><head><title>Values</title> <script type="text/javascript"> <!-- function getid() {
[Code].....
Each text input will have A or B written in by the user, which should automatically place that letters associated ID in its partner field. If any other letter is entered the ID will automatically be left blank.
With the above code I'd need to repeat it over and over for each of the dozens of input fields. The final version wont be using simply A/B either but around 50 possible inputs each with their own ID which would make around 1000 possible variations.
I have the below function and I keep getting the error Lid is not defined.
<script type="text/javascript"> function loadTips(file,ID,File,id){ alert(file); alert(ID);
[Code]....
So my alert Lid comes up with txtHintLees, so it is working up until the alert. Which leads me to believe that maybe it doesn't like being wrapped in "", without "" though firebug halts the process. I tried wrapping it in {} e.g. {loadXMLDocRefresh(File,id)} but that wasn't liked either. I'll stop my list of things I tried that don't work now.
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?
I am trying to "ajaxify" my site. Now I have one problem:
$("#posts").children().remove(); $("#tag-sidebar").children().remove(); $.each(data.Tags_Sidebar, function (indexInArray, valueOfElement) { var insert = $("<li>");
[Code]......
Now when I click one of those links (href1, href2, href3) generated, the click event won't execute! What's the problem? Also, is it right that I have to transfer the valueOfElement over, like I did? What does stopEventPropagation do? Prevent the href from being navigated to? That's what I am trying to do.
I've got some text that I want to change what it says:(63%) on RRP (£80.00) The percentage value and RRP Price will change dependant on the product and its discount. All I want to change with jquery is the text:
When I input my email address on this website, it provides a drop down box with two of my email addresses. The right bottom corner has a few 45 degree lines to indicate the user can change its size. Do you know how to create it? I could not find the code in the source.
I know it's something stupid I'm doing but I can't figure it out. Essentially I'm trying to load two objects with URLs with two websites that can be loaded(displayed) and unloaded(hidden) at the click of a button.
I've spent an hour trying to debug this and I'm at my whits end! I'm doing this with changing the width and height of the divs that contain the objects that will load the websites. But, in Firefox I get an error in the error console saying : loadUnload is not defined. why? code...
can some one help me with a script that opens a <input type=text under this select list when a/b/c choosen? normally this <input type=text, do not have to apear there at all if those options not choosen.
How to validate an input field for a set group of zip codes. Basically I have a list of about 200 zip codes that are valid for this project I'm working on. I tried using the range method and wasn't able to get it to do what I needed it to do. I don't want anyone else to see what the list of correct zip codes are, this is to verify that they are local.
On a simple html page I included jQuery. The page contains a big form including text input fields as well as select list fields (with multiple values).
I want to combine the values from all fields (text and select list) into one (hidden) textarea.
This is to update stock status automatically on a formPlease advisow this is done:When user enters value greater than 0 inside text input field.Status dropdown list selects option: In StockIf value inside text input field is <= 0.
I wanted to create a small DHTML code that created a unordered list of input forms dependent on the number selected from the select dropdown menu. Problem is that it doesn't seem to want to generate the list. I think the variables are within the scope of the function too, and I didn't get an errors from the javascript console when using firebug. The script itself runs, I tested it when I used the old standby alert(); to see if the script was active. Here's the code:
The problem is when i will calculate if quantitiy/buyquantitiy is an integer. The reason is that some products can only be seld as 4 items, and if you press 3 wou should get a message that says "Sorry a quantity of 3 are not aviable because there are 4 items in package". Can transfer 2 varibales into the function? Or have anyone any suggestion how to solve this.