feck Posted October 30, 2007 Share Posted October 30, 2007 HiI have this function for validating user input, that initially checks for missing items in the form of actually no input or the user inputting spaces: var spaceCheck = /[\s{2}]/;for (i=0;i<elemValues.length; i++ )//scrolls through the form elements { if((elemValues[i].value == "")||(spaceCheck(elemValues[i].value))){ //Checks to see if values are empty invalid_Entry +="<li>"+ elemValues[i].id + " is missing</li>"; } } Obviously this is not all the script, the invalid_Entry variable is used to output a box that alert the user to missing values.In Firefox this part of the function works as planned but in IE it only works if I remove the 'spaceCheck' in the if statement.Leaving this in IE doesnt show any error box, removing this part of the if statement lets the error box show.But obviously i can then input spaces and my functionality is reduced.Any ideas as to why this would occur? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 30, 2007 Share Posted October 30, 2007 spaceCheck is not a function, it's a variable. You're trying to use it as a function. What I don't understand is why it would do anything in Firefox except give an error. Link to comment Share on other sites More sharing options...
feck Posted October 30, 2007 Author Share Posted October 30, 2007 God I've been looking at this for hours.Ive been using something like this to test for email validation using a regular expression, but what i did'nt include this time was the .test function as in spaceCheck.test(elemValues.value).Without knowing it, you provided me with the solution with your statement about this not being a function.Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.