gowans007
11-08-2004, 06:00 AM
Ok guys I am writing a simple verification code for uni where you enter your borrowing and what you want to borrow and a purpose.
The validation to check details are entered work fine till I get to purpose.
Basically I have to forms:
one named "purpose" which is a drop down of common options including an other option.
and "purpose_other" for when the other option is selected.
I want the validation to check when other is selected (other is default value on dropdown) that a value must be entered into the purpose_other text box (Blank and a space must not be accepted).
This is letting me down at the moment can you guys help and tell me whats worng???
Thanks for your help guys
CODE FOLLOWS
<SCRIPT LANGIAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function isCurrentod(passedVal){
for (i=0; i<passedVal.length; i++){
if (passedVal.charAt(i) < "0"){
return false
}
if (passedVal.charAt(i) > "9"){
return false
}
}
return true
}
function validCurrentod(inCurrentod){
if (inCurrentod == "") {
return false
}
if (isCurrentod(inCurrentod)) {
return true
}
return false
}
function isRequiredod(passedVal){
for (i=0; i<passedVal.length; i++){
if (passedVal.charAt(i) < "0"){
return false
}
if (passedVal.charAt(i) > "9"){
return false
}
}
return true
}
function validRequiredod(inRequiredod){
if (inRequiredod == "") {
return false
}
if (isRequiredod(inRequiredod)) {
return true
}
return false
}
function validPurpose(inPurpose){
if (inPurpose == "Other") {
if (odForm.purpose_other.value == "") {
return false
}
if (odForm.purpose_other.value == " ") {
return false
}
}
return true
}
function submitIt(odForm){
if (!validCurrentod(odForm.cur_od.value)){
alert ("You must enter a Current Overdraft")
odForm.cur_od.focus()
odForm.cur_od.select()
return false
}
if (!validRequiredod(odForm.req_od.value)){
alert ("You must enter a Required Overdraft")
odForm.req_od.focus()
odForm.req_od.select()
return false
}
if (!validPurpose(odForm.purpose.value)){
alert ("You must enter a Purpose")
odForm.purpose.focus()
odForm.purpose.select()
return false
}
return true
}
// End hiding script -->
</SCRIPT>
The validation to check details are entered work fine till I get to purpose.
Basically I have to forms:
one named "purpose" which is a drop down of common options including an other option.
and "purpose_other" for when the other option is selected.
I want the validation to check when other is selected (other is default value on dropdown) that a value must be entered into the purpose_other text box (Blank and a space must not be accepted).
This is letting me down at the moment can you guys help and tell me whats worng???
Thanks for your help guys
CODE FOLLOWS
<SCRIPT LANGIAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function isCurrentod(passedVal){
for (i=0; i<passedVal.length; i++){
if (passedVal.charAt(i) < "0"){
return false
}
if (passedVal.charAt(i) > "9"){
return false
}
}
return true
}
function validCurrentod(inCurrentod){
if (inCurrentod == "") {
return false
}
if (isCurrentod(inCurrentod)) {
return true
}
return false
}
function isRequiredod(passedVal){
for (i=0; i<passedVal.length; i++){
if (passedVal.charAt(i) < "0"){
return false
}
if (passedVal.charAt(i) > "9"){
return false
}
}
return true
}
function validRequiredod(inRequiredod){
if (inRequiredod == "") {
return false
}
if (isRequiredod(inRequiredod)) {
return true
}
return false
}
function validPurpose(inPurpose){
if (inPurpose == "Other") {
if (odForm.purpose_other.value == "") {
return false
}
if (odForm.purpose_other.value == " ") {
return false
}
}
return true
}
function submitIt(odForm){
if (!validCurrentod(odForm.cur_od.value)){
alert ("You must enter a Current Overdraft")
odForm.cur_od.focus()
odForm.cur_od.select()
return false
}
if (!validRequiredod(odForm.req_od.value)){
alert ("You must enter a Required Overdraft")
odForm.req_od.focus()
odForm.req_od.select()
return false
}
if (!validPurpose(odForm.purpose.value)){
alert ("You must enter a Purpose")
odForm.purpose.focus()
odForm.purpose.select()
return false
}
return true
}
// End hiding script -->
</SCRIPT>