Field Validator, With Inputs In Two Different Divisions. XHTML Strict?
Aug 10, 2009
I am using a javascript to validate that all form fields are filled in here:[URL].. The form input fields in the top div can be validated no problem. However, when I add to the javascript, this section of code:
Code:
if (document.forms['secondform'].firstname.value=="") {
themessage = themessage + " - First Name
";
}
And so on for the next few input boxes, the javascript stops working entirely, passing the user onto the next page without actually validating the fields. I feel it is because I am not calling the input boxes correctly in the javascript, but I am unsure how to do it.
I was thinking that maybe because they are in a different division if I added that in there somewhere I could get it clear up, but no such luck yet.
I am coding xhtml strict for my pages for the first time and I got some one problem with javascript:
I don't know how to modify the scripts to target elements on the page where the name attribute is deprecated.
Eg.
Code:
<form action="test.php" method="post"> <div><input name="text" /> <input type="submit" name="submit" value="search" /></div> </form> how can I modify the code to select such fild in such form ?
how I can get my custom attributes to validate in XHTML Strict? I have to have it validate as it is for a class.Example of the form:
HTML Code: input onkeyup="TF_filterTable(document.getElementById('dataTable'), filter)" size="40" tf_colkey="name"tf_searchtype="substring" /> Example of the JS:
Code: var inputs = frm.getElementsByTagName("INPUT"); for (var i=0;i<inputs.length;i++) { //looping thru all INPUT elements[code].........
this.add = function(element, err) { if ( !('__validate' in form[element]) ) { form[element].__validate = function() { if (this.value=='') { alert(err); this.focus(); return false; } }
} fields.push(form[element]); }
this.check = function() { var len = fields.length; for (var i=0; i<len; i++) if ( !fields[i].__validate() ) return false;
return true; } }
function form_onsubmit(form) { var vform = new Validate_form(form); vform.add('domain_name', 'The domain field is empty'); return(vform.check()); } --></script> <form name="signup" method="post" action="" onsubmit="return form_onsubmit();"> <input type="text" name="domain_name" /> <input type="submit" /> </form>
This is nothing special. just a basic empty field validator. it's probably not as efficient as it could be because it assigns the function to the various elements. It also only supports text fields. I was thinking of allowing a 3rd argument on Validate_form.add to accept something like Validate_form.stock.email/number/etc (functions). ah well..
this code check work fine ,but i have radio button (yes and no) on same .aspx page .if yes(0) and no (1). i need to check if yes is selected (certain palceholder open that have some controls) i already did .but teh problem is i need to check yes is selected or not for radio buton.
I'm working on a financial form that is filled out and then a pdf is outputted (via php).
I'm an xhtml/css and php guy but new to javascript - I'm sure there's got to be a way to do the following with js...
I've got a section for "project costs" with 4 fields (numeric is expected). I'd like to add a 5th field "Total Project Cost" that adds all the inputs of the first 4 fields on the fly as they are typed (or at least, after focus changes).
Also I'd like to have a field which defaults to "10" and a drop down with 3 items that will either add 0, 5 or 10 to the field which defaults to 10.
Using jQuery Validate to do it's job of validating a form. Problem is I need to get at least one phone number recorded in the form - either a Telephone or Mobile (Cell).Is there any inbuilt way of setting up the rules to do this?I have seen the Milk demo for the validate plugin where there's something similar, but the 'name' attribute is the same, something that's not going to be the same for two different text inputs.
I'm writing an ECMAScript tokeniser and parser and trying to find out if I can eliminate the switching from tokenising "/" as start of regex or the division operator depending on the parser feedback - essentially, if I can make the tokeniser independent of the parser. (I have a gut feeling this needs too much special casing to be worth it). Code:
I'm developping an ASP.net web page using JQuery Accordeon . the text inside the Accordeon changes so I'd like to create dynamic divisons that support those changes.
I am now using a strict !DOCTYPE and want to ensure that my pages comply. The Javascript I used to use no longer works - how can I seperate it from the structure of the page?
I was able to achieve Collapsing/Expand at Project Level but not at the vendor level. However, same HTML works fine with IE 8 and FF. The Expand/Collapse at the Vendor Level fails with XHMTL Strict 1.0 and IE 7.
I am looking for HTML validator with the following restrictions: 1. Web server is the localhost (page should be validated locally). 2. The page is dynamic (generated by PHP with client side javascript, which alters the DOM).
I tried the following:
1. Tidy Firefox extenstion (http://users.skynet.be/mgueury/mozilla/). Unfortunately, it doesn't really makes the real DOM validation. In my JS code, I had .inerHTML code injection, but this extension didn't show the injected html code.
2. I am using FireBug Firefox extenstion. This extenstion shows the real DOM, but unfortunately it doesn't validate the HTML. 3. MS developper toolbar for IE and Web Developper Firefox extenstion make only external HTML validation.
/* With RegExp */ function isEmail2(who) { var email=/^[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*.([A-Za-z]){2,4}$/i; return(email.test(who)); } </script>
Everyone around here sure seems to be doing lots of form validation. Fortunately, I have your solution. I've made a form validator that does LOTS AND LOTS of neat stuff. It's still 'beta' because I'm not done with x-browser 100% etc. Well, you can get all the dope here ....
I am trying to include and xml document inside my xhtml document. There are a number of reasons for this including portability, multiple interface generation, and scalability of information. My problem is that javascript is understanding the nodes in my xml document as html elements.
<xml> <book> <title>Lord of the Rings</title> </book> </xml>
If I parse this, the title element cannot be extracted and the page title(in the browser) becomes "Lord of the Rings". Is there a way to exclude this xml node from the xhtml rules?
Maybe you can answer a question for me: I'm reading the preview for XML web development (sitepoint book) and it clearly shows IE rendering XML (the author states IE5 and above); does that mean that IE's problem with XHTML is CDATA and not XML universally? If that's true then IE could render an albeit gimped XHTML page which would explain why HTML 4.01 and XHTML are virtually synonymous in IE 6.
Is there a workaround for this in JavaScript, if the above is true?
Trying to make a simple validator for a form i've just created, but for some reason i cant get it to redirect to the pages upon the IF statements being fulfilled.I've got a feeling its because the form seems to still submit the selection...
Using function FrontPage_Form1_Validator(theForm) and added a function to trap a radio optin like
if (theForm.opt_in.value != "yes" || theForm.opt_in.value != "no") { alert("Please make a choice for the "opt_in" field."); theForm.opt_in.focus(); return (false); }
This traps if neither radio has been clicked BUT when I click on OK in the error message box it continues on without having click on a radio button?
Is the action of clicking the OK in the error message setting to True or something? Any idea of a fix?
Is there any function in JavaScript which validates the date format like isNaN() for numbers? Or have anyone made such function which validates the date entered in the text box i.e. dd-mm-yyyy or yyyy-mm-dd or mm-dd-yyyy or dd/mm/yyy or mm/dd/yyyy or yyyy/mm/dd are only the valid dates??
I'm facing the bug about the failure of innterHTML while reading xhtml content inside a DIV, in fact it has passed as html removing the closing of some nodes. Is there a way to read the content of the div perfectly how it is in the page, kind of:
var obj = document.getElementById("myDIV"); var realContent = obj.toString();
IE6 in standards mode doesn't seem to hide scrollbars on the body element (overflow:hide) Ain't this a quandary. I have it in my head that I need to specify html instead. The scrollbars do hide on Gecko browsers though, so there is definitely a disagreement among browser developers on how to implement scrollbars (as a side note, Gecko browsers with their notoriously bug-ridden resize code seem to always screw up when asked to stretch and scroll divs, even when the page is reloaded on every resize!)
My first thought is to modify the CGI that generates the style sheet as I already have code that deprecates the document type when hidden scroll bars are required on IE6 (but not IE5.) This is based on the simple empirical evidence that the scroll bars are still there on IE6 in standards mode, so the optimal document type (XHTML strict) cannot be used. So I could just change this to output an html style (rather than a body style) for IE6 and lose the deprecation (it wouldn't be needed at this point.)
So the question is this. Given that CGI-based processing of browser versions for these kinds of tweaks is taboo, what would you check on the client side before dynamically generating the style for the body and/or html element? It doesn't seem like you could just send both as this would surely break some older browsers (I know you can do tricks with comments and such, but that only works for NS4 and maybe IE3 AFAIK.)
documentElement is the only thing I can think of that indicates standards mode and NS6/Mozilla support this AFAIK.
IE Conditional comments perhaps? I would hate to hard-code a test for a browser version number into the actual document (for obvious reasons), but I guess it is an alternative if the browser version is exposed to these things.
I don't see any other way to deal with a situation like this than with server-side code that looks at the browser's version number and makes the necessary adjustment. And there are lots of little differences like this that just don't seem to have viable client-only solutions. There's DirectX stuff (probably is an object detect for that) and funky colored scrollbars (hey people ask for them) and document margins (Opera did them slightly differently than the rest as I recall) and now this scrollbar thing.