I have a requirement whereby I must validate that a string matches one of
several patterns:
1. An ISO standard 2 character country code (eg GB, NL) followed by five
digits.
2. An ISO standard 2 character country code (eg GB, NL) followed by an X
followed by five digits.
3. 3 characters in the range a-z followed by 3 digits followed by 2
characters in a specific set (eg MT, AT, DA).
4. 4 characters followed by a hash (#) followed by 3 characters followed by
3 digits followed by a hash followed by 3 characters.
5. 4 characters followed by a hash (#) followed by 3 characters followed by
3 digits followed by a hash followed by 4 characters.
I have been told that a better way to achieve this than using .charAt is by
using something called a regular expression, but I don't really understand
them. Can anyone please advise on the above or alternatively point me in
the direction of a suitable resource on these regular expression things?
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 need a simple, quick and efficient way to logically branch if I find a string is contained in another string in jquery Most other languages this can be resolved in one or two lines and it would be readable.
I have a simple example below showing how when I pass in the value of the value attribute of option node, and then use if operator to check whether parameter is a string or not, even though it's a string, it converts it to false boolean and triggers the else statement rather than calling a function.callback should be a string so why is it saying otherwise?
I have made a basic form, and I need to combine three values within my form, then create an md5 hash of this string.Then assign it to a hidden variable.My form is here...
Or I have created a pastebin of it here, for easy reading: http://pastie.org/1171757.So I need to be able to combine the three values into a string, create a md5 of the string, then call the value of the string into a hidden value all before posting the form.
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.
I am a newbie to javascript. I have an asp text box which I want to validate for the number of characters entered i.e. I dont want user to enter more than 280 characters in the text box.
I have a form generated from a Perl script. The number of check boxes on the form is unknown until the time the form is generated. The names of the check boxes are created from some values in the database, based upon other user input.......<crazy, I know>
The user must choose at least one check box.
So, how can I write a javascript routine that will perform checking on an unknown number of check boxes.
Can anyone explain why this code fails when the set of checkboxes consists of only one.
myForm.update.length returns 0 instead of 1 with the result that I get an alert box even tho' the one checkbox is checked.
function checkForm(myForm) { var numBoxes = 1*myForm.update.length || 0; for(i=0;i<numBoxes;i++) { if(myForm.update[i].checked == true) return true; } alert("Select one or more part components to update"); return false; }}
I am trying to write a js that validates a form with two text inputs. The two inputs are: 'D_techA' and 'D_techB'. I just want to add up (sum) the two input fields (which must be positive numbers) and make sure that they add up to exactly 100 (not more and not less). If they do not add up to 100, then an alert should pop up that says "The two values must add up to exactly 100." I have tried and tried to write a js that does this validation (looking at numerous validation scripts posted in this forum and elsewhere) and I just cannot seem to make it work.
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++) {
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; }
I found some simple code to get a better understanding of validating checkboxes. It validates the checkboxs by their name. Is it possible to validate the checkboxes with the same name but different values? The name of the checkboxes will be an array containing the values of the checkboxes selected.
I have my html like so: <input type="checkbox" name="stuff[]" value="1" onClick="countChoices(this)"> <input type="checkbox" name="stuff[]" value="2" onClick="countChoices(this)"> <input type="checkbox" name="stuff[]" value="3" onClick="countChoices(this)">
And the javascript where I edited "box1=", "box2=", "box3=" is like so: function countChoices(obj) { max = 2;
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?
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 creating this Javascript/XML HTA that is basically a project tracker. I recently added some new fields in the form that are written to the XML file for the project being tracked. This makes the files neither backwards compatible if I use it in a previous version nor forward compatible for future versions. This means if a user is using version 1, I create version 2, he wants to import his old tasks to Version 2, it throws an error. For example if I have a <status> element written in the newest version, but no <status> in the previous, I can no longer use that projects XML file in a previous version.
I tried to use the following code to validate existence of the tag and assign whatever outcome as the variable to write, but it's not working. Theres a few different ways I tried.
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'm experimenting with the load() function. It works fine except when I try to validate (using jQuery Validate).
I have a page called "index.php" which contains the bulk of my code (including the jQuery validate call). The load function calls in a div from another page which we'll call foo.php. The page loads fine, but it just won't validate. I've wondered if you simply can't validate a "load"ed page, but I find that hard to believe.
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"; }.....