if block problem

Results 1 to 2 of 2

Thread: if block problem

  1. #1
    Join Date
    Dec 1969

    Default if block problem

    I need to put an if block in place that will only raise the alert if there is an error. When I put the following if block in it acts weird and doesn’t submit the form. Any idea what I am doing incorrectly?<BR><BR>I have taken out some of the code as not to create a mega post but the problem resides whether or not the other code is still there.<BR><BR>function checkform() <BR>{ <BR> var status;<BR> var strError;<BR> status = true;<BR> strError = ""<BR> <BR> // txtPercentOwn or Ownership<BR>****if (isNaN(document.frmEdit.txtPercentOwn.value)) <BR>**** {<BR>********//alert("Please enter a valid value for the Project Area"); <BR>********strError = strError + ("Please enter a valid value for the Ownership") + "
    ";<BR>********status = false; <BR>**** }<BR>***//if (status = &#039;false&#039;)<BR>***//{ <BR>********alert(strError);<BR>***//}<BR>***<BR>*********<BR>****retur n(status);<BR>*}***** <BR>&#060;/script&#062; <BR><BR>The problem resides in the commented code. Many thanks!<BR>

  2. #2
    Join Date
    Dec 1969

    Default Making it *WAY* too hard...

    Also, isNaN is only reliable *after* you have attempted parseFloat or parseInt on a value.<BR><BR>And you should *never* use
    in JS coding. Always
    , instead.<BR><BR>*****<BR>function checkform() <BR>{ <BR> if ( isNaN(parseFloat(document.frmEdit.txtPercentOwn.va lue)) ) <BR> {<BR> alert("Please enter a valid value for the Ownership
    ");<BR> return false;<BR> }<BR> return true;<BR>} <BR>&#060;/script&#062; <BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts