carl allan Posted November 24, 2005 Share Posted November 24, 2005 Hi, i need help.You see, i need to create a validation using javascript that accepts inputs from users. That is taken care of, my only problem now is that i need to validate that the form only accepts inputs with "@". Only one "@" is accepted, please help me... Link to comment Share on other sites More sharing options...
hacknsack Posted November 25, 2005 Share Posted November 25, 2005 You can use the RegExp method "match" to check: <script type="text/javascript"> var testA = 'Someone@onewww.com'; if(testA.match(/@/g) == null || testA.match(/@/g).length != 1 ){ alert('bad string'); } else { alert('good string'); } </script> Thanks, Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now