jQuery add required to input fields
$(“input”).prop(‘required’,true); DEMO FIDDLE
$(“input”).prop(‘required’,true); DEMO FIDDLE
Assuming you don’t store things like the ‘+’, ‘()’, ‘-‘, spaces and what-have-yous (and why would you, they are presentational concerns which would vary based on local customs and the network distributions anyways), the ITU-T recommendation E.164 for the international telephone network (which most national networks are connected via) specifies that the entire number (including … Read more
Try… for YUI Dom.get(“gadget_url”).set(“value”,””); with normal Javascript document.getElementById(‘gadget_url’).value=””; with JQuery $(“#gadget_url”).val(“”);
Using the official java email package is the easiest: public static boolean isValidEmailAddress(String email) { boolean result = true; try { InternetAddress emailAddr = new InternetAddress(email); emailAddr.validate(); } catch (AddressException ex) { result = false; } return result; }
TLD’s like .museum aren’t matched this way, and there are a few other long TLD’s. Also, you can validate email addresses using the MailAddress class as Microsoft explains here in a note: Instead of using a regular expression to validate an email address, you can use the System.Net.Mail.MailAddress class. To determine whether an email address … Read more
Each field constraint should be handled by a distinct validator annotation, or in other words it’s not suggested practice to have one field’s validation annotation checking against other fields; cross-field validation should be done at the class level. Additionally, the JSR-303 Section 2.2 preferred way to express multiple validations of the same type is via … Read more
You can use string.indexOf(‘a’). If the char a is present in string : it returns the the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
After some research, I think the best answer is Xerces, as it implements all of XSD, is cross-platform and widely used. I’ve created a small Java project on github to validate from the command line using the default JRE parser, which is normally Xerces. This can be used on Windows/Mac/Linux. There is also a C++ … Read more
Another option is to embed a blank image. Any image that suits your purpose will do, but the following example encodes a GIF that is only 26 bytes – from http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever <img src=”data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=” width=”0″ height=”0″ alt=”” /> Edit based on comment below: Of course, you must consider your browser support requirements. No support for IE7 … Read more
The Java runtime library supports validation. Last time I checked this was the Apache Xerces parser under the covers. You should probably use a javax.xml.validation.Validator. import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.*; import java.net.URL; import org.xml.sax.SAXException; //import java.io.File; // if you use File import java.io.IOException; … URL schemaFile = new URL(“http://host:port/filename.xsd”); // webapp example … Read more