ainoy31 Posted August 28, 2008 Share Posted August 28, 2008 Hello- I am having an issue with my javascript validation on my form. Here is the process of my form. On the main form, I have a button with the user can select to add a rating attribute so they can add a phone service. Once that is completed, they are redirected back to the main page that now has a drop down menu to select a phone service. If they try to save and don't select a phone service, the javascript alerts an error message that they need to select one. The user are allow to go back to the rating attribute page and uncheck the rating attribute. This will remove the added phone service and redirect the user back to the main form. To complete the process, they need to click on save. This is my issue with the javascript. It does not save and returns an error message of: Error: 'document.edit_product.primary_rating_product.value' is null or not an object. How can I avoid it from checking to see is a phone service has been selected if even there is no phone service to choose from? Thank you. Here is my javascript code: function validateProductForm() { if(document.edit_product.primary_rating_product.value == 0) { errmsg += 'You must select a Primary Rating Product\n'; } if( errmsg != '' ) { alert( errmsg ); } else { window.document.edit_product.submit(); } function alertuser(field,msg) { alert(msg); field.focus(); } } The drop down menu: <select name="primary_rating_product" class="smaller"> <option value="<?=$data->productItemId?>"><?=$data->name?></option> </select> Hope this makes sense. Much appreciation. Quote Link to comment Share on other sites More sharing options...
ainoy31 Posted August 28, 2008 Author Share Posted August 28, 2008 Resolved. I added a check tag to see if the phone service is turn on or off and validate base on that value. 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.