| | |
JavaScript assistance with alert or error message
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 19
Reputation:
Solved Threads: 0
I have just written a JavaScript file which calculates a taxi fare based on a starting zone, an ending zone, and the length of the taxi ride. The program appears to work fine, however, I would like to be able to display some type of alert or error message though if the proper input is not typed into the prompts. For example, there are only 3 zones available in my program, zones 1,2 and 3. If someone enters a 4 in the user prompt for the zone, I would like to be able to have a message appear indicating that zone 4 is not a valid zone. OR the alert of error message can even come up after the prompts when my HTML page loads completely stating an invalid character has been entered, please refresh the page and try again or something along those lines. If anyone has any suggestions or advice it would be greatly appreciated. I don't even need for anyone to give me the exact code, but just a direction to go into so I can figure it out. Thanks in advance and have a great day.
•
•
Join Date: Sep 2008
Posts: 10
Reputation:
Solved Threads: 2
Your problem description is quite specific - but ultimately what you are talking about is some type of form validation.
Generally form validation falls into two categories:
1. things you can validate purely on the client - because you don't need access to data or logic on the server side,
and
2. things you can only validate on the server - by accessing server data and/or logic.
I don't know which yours falls into. If you have all the information on the page - then you can easily use Javascript for #1. If your problem falls into "requiring server data" - then you can still use JavaScript - but you will need to make an AJAX call... or otherwise you will have to do the validation on the server. Many server side frameworks include form validation as a built i concept in the framework. (such as Struts)
Generally form validation falls into two categories:
1. things you can validate purely on the client - because you don't need access to data or logic on the server side,
and
2. things you can only validate on the server - by accessing server data and/or logic.
I don't know which yours falls into. If you have all the information on the page - then you can easily use Javascript for #1. If your problem falls into "requiring server data" - then you can still use JavaScript - but you will need to make an AJAX call... or otherwise you will have to do the validation on the server. Many server side frameworks include form validation as a built i concept in the framework. (such as Struts)
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: What is the difference between VB script and Java script?
- Next Thread: ajax mysql based dopdown
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captcha captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating stars synchronous toggle unicode variables w3c web webservice \n





