Thursday, January 7, 2010

Typical Validation

Idea Is Form with 5 text box's. validation ,

Form with 5 text boxes, that five text box's are via1,via2,via3,via4,via5 ,

if they filled the via2 textbox then they should enter the via1 also,

Some time user have only one diversion , In that time they have to enter his diversion only in the via1 textbox , not an via2 textbox,

If all fields are empty , then no validation alert,

function validate_form(myForm){
for(var i = 5; i > 1; i--) {
if (myForm.elements['via'+i].value != '' && myForm.elements['via'+(i-1)].value == '')
alert('You need to fill field via' + (i-1) + ' before!');
return false

<form name='myForm' method='post' onsubmit="return validate_form(this);">
<input type="text" id="txt_vai1" name="via1" class="valiMe" />
<input type="text" id="txt_vai2" name="via2" class="valiMe" />
<input type="text" id="txt_vai3" name="via3" class="valiMe" />
<input type="text" id="txt_vai4" name="via4" class="valiMe" />
<input type="text" id="txt_vai5" name="via5" class="valiMe" />
<input type="submit" />

The snippet Source From IRc

No comments:

Post a Comment

Select All,Select None,Select Invertion

Select All Select None Invert Selection

Add to basket JQUERY

Image Fly To Basket
Add to cart
Code take from jbasket fly to basket site,,,,