javascript - Name should have albhabet only -


i have wrote code validate name,whether has albhabet throw error if not have albhabet below code should show error,but not show error message

var nameexpression = '/^[a-za-z]/'; var name = 'hello123'; if ( !nameexpression.test(name) )     alert('error:please enter valid name');  

var nameexpression = /^[a-za-z]+$/; var name = 'hello123'; if ( !nameexpression.test(name) )     alert('error:please enter valid name'); 

explanation: 1.nameexpression should not string 2. should use end delimeter such '$' eg var nameexpression = /^[a-za-z]$/;


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -