oninput="value=value.replace(/[^\d]/g,'')"
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>input</title> </head> <body> 只能输入纯数字的输入框:<input type="text" name="" oninput="value=value.replace(/[^\d]/g,'')"> </body> </html>
oninput="value=value.replace(/[^\d]/g,'')"
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>input</title> </head> <body> 只能输入纯数字的输入框:<input type="text" name="" oninput="value=value.replace(/[^\d]/g,'')"> </body> </html>