Results 1 to 5 of 5

Thread: client side validation

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89
    does anyone have an example of the following:

    javascript validation on a form

    if successfull call aspcode to process the form into a database. I have the javascript working but i cant get it to process correctly. Any example would be great

  2. #2
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    pretty busy at work right now, so dont have time to write up the code for you, but if you form validation is working, just do the following:

    Code:
    <SCRIPT LANGUAGE=javascript>
    <!--
    
    function checkform(){
    
       //do you checking here
       if successful 
    	document.form1.submit()
    
    }
    
    
    -->
    
    </SCRIPT>
    do you need more than this?
    dvst8
    Secret to long life:
    Keep breathing as long as possible.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89
    I have the javascript working fine. It does all the validation..


    function validPass(inPass) {
    if (inPass == "") {
    return true
    }
    if (inPass.length >=6) {
    return true
    }

    return false
    }



    function submitIt(JoinForm) {

    if (JoinForm.oldPass.value == "") {
    alert("Please enter password.")
    JoinForm.oldPass.focus()
    return false
    }

    if (JoinForm.newPass.value == "") {
    alert("Please enter your password.")
    JoinForm.newPass.focus()
    JoinForm.newPass.select()
    return false

    }


    if (!validPass(JoinForm.newPass.value)) {
    alert("Your password must be at least 6 characters.")
    JoinForm.newPass.focus()
    JoinForm.newPass.select()
    return false
    }

    if (JoinForm.confirmNewPass.value == "") {
    alert("Please enter your password.")
    JoinForm.confirmNewPass.focus()
    JoinForm.confirmNewPass.select()
    return false

    }
    if (JoinForm.confirmNewPass.value != JoinForm.newPass.value) {
    alert("The passwords must be the same.")
    JoinForm.confirmNewPass.focus()
    JoinForm.confirmNewPass.select()
    return false
    }

    document.frmPass.submit();



    But the form is not bing called correctly. I sort of solved it by posting to another form that does the procesing but why cant i post to the same form?

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    Is the submitIt(JoinForm)function being called from frmPass's onSubmit event? If it is then your last line: document.frmPass.submit();
    would not be allowed because it would endlessly loop.
    "People who think they know everything are a great annoyance to those of us who do."

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89
    i am calling it in the following manner:

    <form onSubmit="return submitIt(this)" method="post" action="changePass.asp" id="frmPass" name="frmPass">

    i have the following aspcode that i am trying to process at the beginning of the page

    <%Sub ChangePass()
    on error goto 0
    dim dbconn
    dim strNewPass
    dim strLoginCheck
    dim rstUpdate
    Dim qryUpdate
    dim blnSuccess

    Set dbConn= Server.CreateObject("ADODB.Connection")
    dbConn.Open connString
    'student
    set rstUpdate = Server.CreateObject("ADODB.Recordset")


    strLoginCheck="Y"


    qryUpdate="UPDATE table SET variable='"& Request.form("variable") &"', variable='"& variable & "' WHERE variable = " & session("varaible")

    set rstUpdate = dbConn.Execute(qryUpdate)
    set rstupdate=dbconn.Execute("standard sql))
    if not rstUpdate.EOF then
    if rstUpdate("LOGIN_CHECK")="Y" then
    closers(dbConn)
    closeRS(rstUpdate)
    Response.Redirect("goodpage.asp")
    else
    closers(dbConn)
    closeRS(rstUpdate)
    Response.Redirect("badpage.asp")
    end if
    end if
    End Sub

    If Request.Form("Submit1") = "GO" Then
    call changePass()
    end if%>


    right now when i click the go button it works through the javascript but doesnt touch the asp code. But when i post to another page to process works great. I change the bottom of the java script to :

    return false
    }
    return true'if successfull
    }
    i thought that might be a loop like you guys said.

Posting Permissions

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



Click Here to Expand Forum to Full Width