News

Log In Sponsors
Partner Sites

Alert message is generating in all the fields.



I was working with an issue but could not figure it out. I need your help on this issue. I have a jsp file which shows Name field, Type drop down and Supervision Time Drop down. In original code when we select "Please select a Type" from the Drop down list and click on "Save" Button the pop up displays "Please select a Device Type" in the browser. I have to show some pop up message for oher type from the "Type" drop down list. Now the issue occuring is when I put a else condition for the other type for "Type" drop down list and generate any message (for example: "You have selected other Type"), this alert message is generating in every field of this page. But I don't want this alert message in every field. I need it only for the other Type form the "Type" drop down list. There is a validate() method in this JSP which generate these alert messages. I am looking for your your suggession to generate the alert message only for the other type of "Type" drop down list. function validate() { if ( true == containsInvalidCharacter( 'Name', document.formSettings.name.value ) ) { return false; } if ( null != document.formSettings.superTm ) { var superTm = document.formSettings.superTm.value; if ( true == document.formSettings.supervision.checked && ( -1 > superTm || superTm > 129600 ) ) { alert( "Please select 1 <= Supervision Time <= 129600" ); return false; } var voldSuperTm = <%=oldSuperTm%>; if ( voldSuperTm != superTm && -1 != voldSuperTm ) { var scs = parseInt( voldSuperTm / 3 ); var hrs = parseInt( scs >= 3600 ? (scs / 3600) : 0 ); var mns = parseInt( scs >= 60 ? ((scs - (3600 * hrs)) / 60) : 0 ); scs -= ((3600 * hrs) + (60 * mns)); var msg = ""; if ( 0 != hrs ) { msg += hrs + " hour(s) "; } if ( 0 != mns ) { msg += mns + " minute(s) "; } if ( 0 != scs ) { msg += scs + " second(s) "; } alert( "It may take " + msg + "for supervision time to change."); } } if ( null != document.formSettings.type.options ) { var selectedTypeOption = document.formSettings.type.selectedIndex; var selectedTypeValue = document.formSettings.type.options[selectedTypeOption].value; if ( selectedTypeValue == "none" ) { alert( "Please select a device type" ); } else { alert( "You have selected other Type" ); } } return true; }

Click here to read the whole forum topic