We help IT Professionals succeed at work.

call a stored procedure in javascript based to check form data

Last Modified: 2008-03-15
Hi all,

First off, I am not sure if this is possible, but would like to know if I can call a procedure in javascript.  I am using a coldfusion and html.  Javascript to validate the form when the user clicks submit.  
Basically, what I have is a form with several fields.  One of the fields is a userid.  I need to verify that this is a valid userid and that run javascript validation on the other fields (field isn't empty....etc...).  I want to set this up so if they've entered an invalid userid I can alert them without losing the data entered in the form.  (I have created a stored procedure which checks for the userid.  There is another procedure which does the saving of the form data. )Not sure how to go about this because they want this all as one process.  Any help would be greatly appreciated.
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


Version 7.  So how would I go about using ajax javascript to make the call to the procedure?

Well Ajax is Javascript calling back to the server.

So Ajax could make a call to a CFC or CFM page which executes the SP and returns a boolean true or false depending on the result.

In CF8, this is really easy, with CF7 you will need to use something like AjaxCFC or similar.


Do you have an example of this, or know where I could find it?


man, there's a lot here.  I'm not sure what I'm looking for....Was there a specific example here?

Well there isn't going to be an example doing exactly what you want of course, but have a look here.


This is a very simple example that passes a string from a form and returns the same string. You just need to modify it to pass the username from the form. And return the result of your SP check.


Is there any other way of going about this?

No, not unless on page load you populate a javascript array with all usernames, but that would be slow, depending on the number of users.

All the systems that you see out there like gmail, hotmail that tell you if the username is available do it in Ajax. Without Ajax you would need to post (refresh) the page to see the result, is that an option here?


No, I don't want to refresh the page.

You can do it with hidden iFrames also, but that it considered bad practice and the Ajax stuff isn't that hard, if upgrading to CF8 is an option it's all built in and even easier.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.