Showing Error Using Java Script
-
Hi There, I had written funtion in js file to check two textbox values.Funtion is if textbox1 value is less than textbox 2 value then it should throw an error. I am Calling this funtion on click of save button.There is no problem in executing this funtion.But my problem is that when I Click on Save button this funtion gets executed but after the error occure then also code written on button for save button get executed.Now I want to restrict this code from executing after error occure in js funtion.Is it possible. If anybody knows please help. Thanks
-
Hi There, I had written funtion in js file to check two textbox values.Funtion is if textbox1 value is less than textbox 2 value then it should throw an error. I am Calling this funtion on click of save button.There is no problem in executing this funtion.But my problem is that when I Click on Save button this funtion gets executed but after the error occure then also code written on button for save button get executed.Now I want to restrict this code from executing after error occure in js funtion.Is it possible. If anybody knows please help. Thanks
You may want to post some of your code here to help explain your problem and allow for someone to help you out more easily. Regards, --Perspx
"A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year."
-Andrew Tanenbaum
"Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer."
-Fred Brooks -
Hi There, I had written funtion in js file to check two textbox values.Funtion is if textbox1 value is less than textbox 2 value then it should throw an error. I am Calling this funtion on click of save button.There is no problem in executing this funtion.But my problem is that when I Click on Save button this funtion gets executed but after the error occure then also code written on button for save button get executed.Now I want to restrict this code from executing after error occure in js funtion.Is it possible. If anybody knows please help. Thanks
Try something like this for your Javascript-
function validateValues(theForm) {
var error = "";
if (theForm.textbox1 < theForm.textbox2) {
reason = "-textbox1 must be greater than textbox2."
}
if (reason != "") {
alert("Some fields need correction:\n" + reason);
return false;
}
return true;
}...and the form should contain-
<form method=POST action=action.aspx name=Demo onSubmit='return validateValues(this)'>
Good luck!
Ranjit Viswakumar Professional Services Specialist http://hostmysite.com/?utm\_source=bb