How can I write ad check for a specific character string in a text field?
If someone types in this identification number in a textfield.
Upon submit, it will look if it starts with "D" IE: D959344843
If it does, display a DIV on the page. If not, prompt an error alert message.
-=-=-=-=-=-=-=-=-=-=-=--=
New addition
How can I code this on my page and make it work?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Test</title>
<script type="text/javascript"> var mystring = 'D59344843';
if(mystring.substring(0, 1) == 'D'){ //display a DIV alert('cool'); }else{ alert('error is no kewl'); } </script>
</head>
<body> <input name="yourtextfield" value="" type="text" /> <input name="" type="submit" /> </body> </html>