socalnate Posted October 29, 2007 Share Posted October 29, 2007 Javascript noobie here. So I'm working on form validation and I'm simply adding up all the input data and checking to make sure it equals 100. If it doesn't, then I want a popup and to focus on the div container enclosing the inputs "Sum Must Equal 100 Percent." How do I get the popup to popup? Here's what I got so far: <script type='text/javascript'> // Make quick references to our fields var action_percent = document.getElementById('action_percent'); var adventure_percent = document.getElementById('adventure_percent'); var animation_percent = document.getElementById('animation_percent'); var arcade_percent = document.getElementById('arcade_percent'); var fighting_percent = document.getElementById('fighting_percent'); var casino_percent = document.getElementById('casino_percent'); var defense_percent = document.getElementById('defense_percent'); var board_percent = document.getElementById('board_percent'); var sports_percent = document.getElementById('sports_percent'); var puzzle_percent = document.getElementById('puzzle_percent'); var multiplayer_percent = document.getElementById('multiplayer_percent'); var driving_percent = document.getElementById('driving_percent'); var shooter_percent = document.getElementById('shooter_percent'); var classic_percent = document.getElementById('classic_percent'); var gadget_percent = document.getElementById('gadget_percent'); var webcam_percent = document.getElementById('webcam_percent'); // Sum the inputs var total_percent = action_percent + adventure_percent + animation_percent + arcade_percent + fighting_percent + casino_percent + defense_percent + board_percent + sports_percent + puzzle_percent + multiplayer_percent + driving_percent + shooter_percent + classic_percent + gadget_percent + webcam_percent if(total_percent != 100){ } Quote Link to comment Share on other sites More sharing options...
micah1701 Posted October 29, 2007 Share Posted October 29, 2007 if(total_percent != 100){ alert("Your total does not equal 100. Your total = " + total_percent); } 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.