Regular Expression for IP Validation

Here is the regular expression for IP validation

“^([01]?\\d\\d?|2[0-4]\\d|25[0-4])\\.” +
“([01]?\\d\\d?|2[0-4]\\d|25[0-4])\\.” +
“([01]?\\d\\d?|2[0-4]\\d|25[0-4])\\.” +
“([01]?\\d\\d?|2[0-4]\\d|25[0-4])$”

this will work for range till 255.255.255.255

you can use this javascript validation with regular expression.

Advertisements

jQuery required validation

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" 
src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.setDefaults({
	debug: true,
	success: "valid"
});;
</script>

  <script>
  $(document).ready(function(){
    $("#myform").validate({
  rules: {
    fruit: "required"
  }
});
  });
  </script>
  <style>#fruit { margin-left: .5em; float: left; }
  	#fruit, label { float: left; font-family: Arial, Helvetica, sans-serif; font-size: small; }
	br { clear: both; }
	input, select { border: 1px solid black; margin-bottom: .5em;  }
	select.error { border: 1px solid red; }
	label.error {
		background: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/unchecked.gif') no-repeat;
		padding-left: 16px;
		margin-left: .3em;
	}
	label.valid {
		background: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/checked.gif') no-repeat;
		display: block;
		width: 16px;
		height: 16px;
	}
</style>
</head>
<body>

<form id="myform">
  <label for="fruit">Please select a fruit</label>
  <select id="fruit" name="fruit" title="Please select something!"
    <option value=""></option>
    <option value="1">Banana</option>
    <option value="2">Apple</option>
    <option value="3">Peach</option>
  </select>
  <br/>
  <input type="submit" value="Validate!" />
</form>

</body>
</html>

you can use this for any input validation.
Its very easy...use it,,,,,,!!!!!!!!!!!!!1111

Show and Hide DIV using javascript

<html>
<head>

<script language=”JavaScript” type=”text/javascript”>
function Test(rad){
var rads=document.getElementsByName(rad.name);
document.getElementById(‘courier’).style.display=(rads[1].checked)?’none’:’none’;
document.getElementById(‘courier’).style.display=(rads[1].checked)?’block’:’none’;
}
</script></head>

<body>
<input name=”selection” type=”radio”  onclick=”Test(this);”/>
<input name=”selection” type=”radio”  onclick=”Test(this);”/>

<div id=”courier”>Select your courier:<br />
Blah blah….Dropdown to come here</div>

</body>

</html>

when you load the page nothing will be selected.

but when you select first radio button it will hide the div and when  second radio button selected it will show the div.

you can use this for table hide .

its so simple with javascript.

Try this ……..!!!!!!!!!!!