Skip navigation
Currently Being Moderated

need help with jquery ajax form field valiation against database

May 9, 2011 12:06 PM

Hi,

 

I had a form element like this

<input type="text" value="" name="myid" id="id"/>

 

this input coming from database and there i no wy to add onblur evnt.

 

so i thought of using jquery  blur event.

 

I need help in that when user enters his id like cf1234 of length six then onblur event hs to fire and check that id entered with database value.

 

if record foung in database i have to alert user id is valid and if not alert user with id not valid and stop form submit.

 

dO WE HaVE ANY EXAMPLE THAT HELPS.

 

 

Appreciate your help.

 

Thanks

 
Replies
  • Currently Being Moderated
    May 13, 2011 6:27 AM   in reply to cfnew

    You can try this, and for the CFC method using javascript you can look here :

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461 172e0811cbec22c24-79f9.html

    ITs not perfect, and probbly will need some twekaing ,,,, but its somthgin to start from

     

     

     

    <script type="text/javascript">
    var formSubmitFlag = false;


    // Function that is binded to the keyUp of the textbox
    function onTextboxChange(textValue)
    {
    if(textValue.length == 6)
    {
      alert('6 carecters - '  + textValue);
      // Do validation here ...
      // You can use CFC with java script
      // and if its validated change the formSubmitFlag = true so the form can be submited
      formSubmitFlag = true;
     
     
    // end if
    }
    // End function
    }


    // Form submit control
    function checkFormSubmitFlag()
    {
    if(!formSubmitFlag)
    {
      alert('Can not submit yet until the field is validated ...');
    }

    return formSubmitFlag;
    }

     

    </script>

     

    <cfform onsubmit="return checkFormSubmitFlag();" name="myForm">

    <cfinput type="text" name="mytextbox" onKeyUp="onTextboxChange(this.value);">
    <input type="submit" />
    </cfform>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points