Commit 494944714cca89ba0f5eb78493df38d43191c793
1 parent
bfb71644
fixed javascript validation to work with ns4
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1626 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
32 additions
and
8 deletions
presentation/lookAndFeel/knowledgeTree/js/misc.js
| @@ -26,19 +26,43 @@ function isEmailAddr(email) | @@ -26,19 +26,43 @@ function isEmailAddr(email) | ||
| 26 | 26 | ||
| 27 | function validRequired(formField,fieldLabel) | 27 | function validRequired(formField,fieldLabel) |
| 28 | { | 28 | { |
| 29 | - var result = true; | ||
| 30 | - if (formField.value.length == 0) | ||
| 31 | - { | 29 | + var result = true; |
| 30 | + | ||
| 31 | + if (formField){ | ||
| 32 | + switch(formField.type){ | ||
| 33 | + case "select-one": | ||
| 34 | + if (formField.selectedIndex == 0 || formField.options[formField.selectedIndex].text == "" || formField.options[formField.selectedIndex].text == "None"){ | ||
| 35 | + result = false; | ||
| 36 | + } | ||
| 37 | + break; | ||
| 38 | + case "select-multiple": | ||
| 39 | + if (formField.selectedIndex == -1){ | ||
| 40 | + result = false; | ||
| 41 | + } | ||
| 42 | + break; | ||
| 43 | + case "text": | ||
| 44 | + case "textarea": | ||
| 45 | + if (formField.value == "" || formField.value == null){ | ||
| 46 | + result = false; | ||
| 47 | + } | ||
| 48 | + break; | ||
| 49 | + default: | ||
| 50 | + if (formField.value == "" || formField.value == null){ | ||
| 51 | + result = false; | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + if (!result) { | ||
| 32 | if (fieldLabel == "selected") { | 57 | if (fieldLabel == "selected") { |
| 33 | alert('Please enter a value for the ' + fieldLabel +' field.'); | 58 | alert('Please enter a value for the ' + fieldLabel +' field.'); |
| 34 | } else { | 59 | } else { |
| 35 | - alert('Please enter a value for the "' + fieldLabel +'" field.'); | ||
| 36 | - } | 60 | + alert('Please enter a value for the "' + fieldLabel + '" field.'); |
| 61 | + } | ||
| 37 | formField.focus(); | 62 | formField.focus(); |
| 38 | - result = false; | ||
| 39 | - } | 63 | + } |
| 64 | + | ||
| 40 | return result; | 65 | return result; |
| 41 | - | ||
| 42 | } | 66 | } |
| 43 | 67 | ||
| 44 | function allDigits(str) | 68 | function allDigits(str) |