Question : Check entries from user with Javascript

I am trying to catch some user errors using javascript but having some issues. In my code behind I have the following:
btnSave.Attributes.Add("onclick", "SaveLP();return false;")

Shouldn't this work? It works when there is an error by the users but if everything is correct, it doesn't go to the backend for processing. Thanks for your help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
function IsNumeric(strString)
                   //  check for valid numeric strings	
                   {
                   var strValidChars = "0123456789.-";
                   var strChar;
                   var blnResult = true;
                 
                   if (strString.length == 0) return false;
                 
                   //  test strString consists of valid characters listed above
                   for (i = 0; i < strString.length && blnResult == true; i++)
                      {
                      strChar = strString.charAt(i);
                      if (strValidChars.indexOf(strChar) == -1)
                         {
                         blnResult = false;
                         }
                      }
                   return blnResult;
                   }

		        
		        function SaveLP(){
		        
		            var txtLessonName = document.getElementById('ctl00_MainContent_txtLessonName').value;
				    var txtAgeLow = document.getElementById("ctl00_MainContent_txtAgeLow").value;
		            var txtAgeHigh = document.getElementById("ctl00_MainContent_txtAgeHigh").value;
		           
		           if (!IsNumeric(txtAgeLow) * 1)
                    {
                        alert("Please enter a number in Age Range Low and High.");
					    return false;
                    }
                    if (!IsNumeric(txtAgeHigh) * 1)
                    {
                        alert("Please enter a number in Age Range Low and High.");
					    return false;
                    }
				    if (txtLessonName == '') 
				    {
					    alert("Please enter a name for this Lesson Plan");
					    return false;
				    }
				    if (txtAgeLow == ''||txtAgeHigh==''||txtAgeLow == '0'||txtAgeHigh=='0') 
				    {
					    alert("Please enter a number in Age Range Low and High.");
					    return false;
				    }
				     if (txtAgeLow > txtAgeHigh )
                    {
                        alert("Age Range Low must be less then Age Range High.");
                        return false;
                    }
				    return true;
			    }

Answer : Check entries from user with Javascript

Random Solutions  
 
programming4us programming4us