Eddy73 Posted August 23, 2010 Report Share Posted August 23, 2010 <html> <body> <body> <script language="JavaScript"> <!-- function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("Password","accsept","sex"); // Enter field description to appear in the dialog box var fieldDescription = Array("Please enter your Password","Please accsept-Terms and conditions","Please enter your gender"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } // --> </script> <form name="formcheck" onsubmit="return formCheck(this);"> <br/> Password: <input type=password name="Password" style="left: 271px; top: 482px; width: 160px; height: 19px;background-color:lightblue;">(Must contain atleast 1 digit and 5 letters) <br/> <input type="radio" name="sex" value="male" /> Male <input type="radio" name="sex" value="female" /> Female <br/> <small style="font-family;color:red"><b>I have Have read and agree to</small><a href="user terms.htm" target="_blank" style="font-family;color:red">User Terms and Conditions.</a> <input type="checkbox" name="accsept" value="Yes" /><br/><br/> <form name="input" action="html_form_submit.asp" method="get"> <input type="submit" value="Submit Form"> </form> </body> Quote Link to comment Share on other sites More sharing options...
indoom Posted August 23, 2010 Report Share Posted August 23, 2010 kādu kļūdu tad rāda? Quote Link to comment Share on other sites More sharing options...
Леший Posted August 23, 2010 Report Share Posted August 23, 2010 Pliks JS, uzrakstīts bez tabulācijas, netie izmantots code tegs, gribi, lai kāds te kaut ko saprastu? Quote Link to comment Share on other sites More sharing options...
vitao.web Posted August 23, 2010 Report Share Posted August 23, 2010 (edited) SAGLABA SAVU UBER KODU SEIT UN IEDOD LINKU :) Tad varbūt kāds sāks kaut ko skatīt. Jo tavs kods ir garš nevis 2 - 5 rindiņas :D Edited August 23, 2010 by vitao.web Quote Link to comment Share on other sites More sharing options...
davisca Posted August 27, 2010 Report Share Posted August 27, 2010 (edited) iekš switch(obj.type){} nav case, lai apstrādātu tipus 'password' un 'checkbox' Edited August 27, 2010 by davisca Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.