js input only allow double type

 obj.keypress(function (event) {
                    if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
                        event.preventDefault();
                    }
                });


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
字符转的各种转换函数库,用这个库,字符串的各种转换再也不头疼 //-------------字符串转数字-------------- int CString_numberStr_2_int(CString str); int stdString_2_int(std::string str);//std string 字符串转int int std_hexString_2_int(std::string str);//std string 字符串转int double CString_2_double(CString in); double stdString_2_double(std::string str);//std string 字符串转double unsigned int hexString_2_u32(std::string str); //-------------数字转字符串-------------- CString CString_int_2_numberStr(int n); CString CString_int_2_numberStr6(int n); std::string stdString_int_2_numberStr(int a); CString double_2_number_CString(double n); std::string double_2_number_String(double a); CString GetCurrWorkingDir(); //获得当前工作路径,不含最后一个字符“\” CString ascii_2_cstring(int ascii);// 把ascii字符转换成对应的字符,返回cstring类型 //-------------字符串转字符串-------------- std::string CString_2_stdString(CString str); CString stdString_2_CString(std::string str); void CString_2_charP(CString str,char *q); //cstring change to ansi string //-------------判断字符串类型-------------- bool is_a_double_type_string(CString str); //-------------字符串复杂操作-------------- int break_string(std::string instr, std::string subStr, vector<std::string>* subs); //以subStr为标记切割instr为多个单词,存储于subs std::string super_CString::getTimeString(bool fgf);//获得表示当前时间的字符串,fgf表示是否需要分隔符 std::string super_CString::getDateTimeString(bool fgf);//获得表示当前时间和日期的字符串,fgf表示是否需要分隔符 std::string getDateString(bool fgf); //获得表示当前日期的字符串,fgf表示是否需要分隔符 std::string string_trim_LR_space(std::string str);//去除字符串前后的空白字符 std::string string_trim_L_space(std::string str);//去除字符串左边的空白字符 std::string string_trim_R_space(std::string str);//去除字符串右边的空白字符 //-------------GUI相关-------------- CString get_CEdit_text(CEdit* edit); //-------------文件、路径相关-------------- CString calc_CurrWorkingDir_filename(CString str);//返回程序运行的当前路径+filename CString calc_work_full_filename(CString filename,CString path);//path为路径,如果path为空返回程序运行的当前路径+filename,否则返回path+filename。 std::string GetCurrWorkingDir_stdString(); std::string calc_CurrWorkingDir_filename(std::string str); std::string calc_work_full_filename(std::string filename,std::string path);

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值