hello
i am trying to do a validation form but i ended up with one that only works for chrome, not on IE not on Firefox! don’t know why!!! and another problem it looks like that the return false doesn’t even work, it proceeds to the next page anyway
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="-1")
{
alert(alerttxt);
return false;
}
else
{
return true;
}
}
}
/*function alertt(thisform)
{alert(thisform);}*/
function validate_form(thisform)
{
//alert('hi');
with (thisform)
{
if (validate_required(i_am_a,"i_am_a must be filled out!")=="-1")
{i_am_a.focus();
return false;}
}
function validate_form(myForm){
var select = myForm.getElementsByTagName('select'); // returns all the select forms in a type of array
var numSF = select.length; // number of select forms
var selectedIndex;
for (var i = 0; i < numSF ; i += 1){
selectedIndex = select[i].selectedIndex;
if (!selectedIndex){ // ! means not
alert(select[i].name + ' must be filled out or selected! ');
select[i].focus();
return false;
}
}
myForm.submit();
}
but there is a problem i didn’t mention
i need it to work for any thing in the form such as input type=“text” and textarea and so on, and also not for each and every one should be validated, only the fields that i want them to be validated
such as username, password, DOB, and such but not a field like address,