Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <script type="text/javascript">
- function validasi_input(form){
- if (form.telp.value != ""){
- var x = (form.telp.value);
- var status = true;
- var list = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
- for (i=0; i<=x.length-1; i++)
- {
- if (x[i] in list) cek = true;
- else cek = false;
- status = status && cek;
- }
- if (status == false)
- {
- alert("Telp harus angka!");
- form.telp.focus();
- return false;
- }
- }
- return (true);
- }
- </script>
- </head>
- <body>
- <form method="post" action="aksi.php" onsubmit="return validasi_input(this)">
- <p>Telp/Hp : <input name="telp" type="text"></p>
- <p><input name="" type="submit" value="Submit"></p>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment