jnvnsn Posted July 11, 2011 Share Posted July 11, 2011 var NumberToTest = 1234; var IsFound = /^\d+$/.test(NumberToTest); document.write(IsFound); Help anyone on how to restrict 4 digits. This works but it is true even though how many digits is being entered. HELP Link to comment https://forums.phpfreaks.com/topic/241700-validating-4-digitshelp/ Share on other sites More sharing options...
Adam Posted July 11, 2011 Share Posted July 11, 2011 Remove the plus, which means 1 or more, and add "{4}". That will require exactly 4 repetitions of the token.. /^\d{4}$/ Link to comment https://forums.phpfreaks.com/topic/241700-validating-4-digitshelp/#findComment-1241356 Share on other sites More sharing options...
jnvnsn Posted July 11, 2011 Author Share Posted July 11, 2011 Thank You MrAdam! One more thing, where can i find good tutorial about this? Link to comment https://forums.phpfreaks.com/topic/241700-validating-4-digitshelp/#findComment-1241365 Share on other sites More sharing options...
Adam Posted July 11, 2011 Share Posted July 11, 2011 http://www.regular-expressions.info/tutorial.html Link to comment https://forums.phpfreaks.com/topic/241700-validating-4-digitshelp/#findComment-1241366 Share on other sites More sharing options...
jnvnsn Posted July 11, 2011 Author Share Posted July 11, 2011 Been a great help! Thanks! Link to comment https://forums.phpfreaks.com/topic/241700-validating-4-digitshelp/#findComment-1241369 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.